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

实现选中字符串分词 例如 TomLikes eat iceCream. 分词为 tom|likes|eat|ice|cream|.

This commit is contained in:
zhangbk1
2024-04-02 17:39:23 +08:00
parent 6b661e5e37
commit 7edf6f8d13
5 changed files with 231 additions and 81 deletions

View File

@@ -3,7 +3,7 @@
import * as vscode from 'vscode';
import * as TextConversion from './main-code/text-conversion';
type ConvertFunction = (selectionText: string) => string | undefined;
type ConvertFunction = (selectionText: string) => string;
// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed
@@ -28,7 +28,7 @@ export function activate(context: vscode.ExtensionContext) {
if (!editor) {
return;
}
console.log('============ start convert ============');
let document = editor.document;
let selection = editor.selection;
@@ -46,7 +46,7 @@ export function activate(context: vscode.ExtensionContext) {
return;
}
// 当转换后文本与转换前相同时,跳过转换
// 当转换后文本与转换前相同时,跳过转换,避免形成 Ctrl + Z 撤销历史记录
if (converted === text) {
console.log('selection text is same to converted text, skip replace contents.');
return;