1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

多行内容逐行处理;更新测试用例;测试用例可以指定EOL换行符;transformMutliLineText 通过所有测试用例

This commit is contained in:
2024-04-03 00:07:12 +08:00
parent c7a16581ab
commit 30224cfeb6
8 changed files with 244 additions and 90 deletions

View File

@@ -2,8 +2,7 @@
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';
import * as TextConversion from './main-code/text-conversion';
type ConvertFunction = (selectionText: string) => string;
import { ConvertFunction, EOL } from './type-definition/convert-function-type';
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
@@ -32,12 +31,13 @@ export function activate(context: vscode.ExtensionContext) {
console.log('============ start convert ============');
let document = editor.document;
let selection = editor.selection;
let eol: EOL = document.eol === vscode.EndOfLine.CRLF ? '\r\n' : '\n';
// 获取选中的文本
let text = document.getText(selection);
// 转换文本
const converted = convertFunction(text);
const converted = convertFunction(text, eol);
console.log('converted', converted);
// 无法转换时,跳过转换