From c3199faa6504e48037fe46a82aad65804133693e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Tue, 9 Apr 2024 10:29:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=8F=B3=E9=94=AE=E8=8F=9C=E5=8D=95=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E9=80=89=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- src/extension.ts | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72edaeb..c800efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Supports scrolling conversion via shortcut keys `Ctrl + Alt + [` and `Ctrl + Alt + ]` (simultaneously supports multi-line selection conversion) 支持通过快捷键循环转换 (同时支持多行选区转换) +- New: Supports multi-selection conversion (支持多选区转换) +- New: Supports scrolling conversion via shortcut keys `Ctrl + Alt + [` and `Ctrl + Alt + ]` (also supports multi-selection conversion) 支持通过快捷键循环转换 (同时支持多选区转换) ## 1.0.7 diff --git a/src/extension.ts b/src/extension.ts index b19aab8..af5d0f0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -28,16 +28,15 @@ export function activate(context: vscode.ExtensionContext) { // 选中文本改变时触发 const onTextEditorSelectionChangeCallback = (textEditor: vscode.TextEditor, selections: readonly vscode.Selection[]) => { - // 获取选中的文本 - const text: string = textEditor.document.getText(selections[0]); - selectTextLength = text.length; - // 获取选中的文本块 const textList: string[] = []; + let tmp_selectTextLength = 0; for (const selection of selections) { const text = textEditor.document.getText(selection); textList.push(text); + tmp_selectTextLength += text.length; } + selectTextLength = tmp_selectTextLength; // 更新 _textSelectionLength (用于判断是否展示右键菜单) vscode.commands.executeCommand('setContext', '_textSelectionLength', selectTextLength);