判断是否展示右键菜单逻辑支持多选区
This commit is contained in:
parent
ab1d6770bd
commit
c3199faa65
@ -27,7 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### 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
|
## 1.0.7
|
||||||
|
|
||||||
|
@ -28,16 +28,15 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
// 选中文本改变时触发
|
// 选中文本改变时触发
|
||||||
const onTextEditorSelectionChangeCallback = (textEditor: vscode.TextEditor, selections: readonly vscode.Selection[]) => {
|
const onTextEditorSelectionChangeCallback = (textEditor: vscode.TextEditor, selections: readonly vscode.Selection[]) => {
|
||||||
// 获取选中的文本
|
|
||||||
const text: string = textEditor.document.getText(selections[0]);
|
|
||||||
selectTextLength = text.length;
|
|
||||||
|
|
||||||
// 获取选中的文本块
|
// 获取选中的文本块
|
||||||
const textList: string[] = [];
|
const textList: string[] = [];
|
||||||
|
let tmp_selectTextLength = 0;
|
||||||
for (const selection of selections) {
|
for (const selection of selections) {
|
||||||
const text = textEditor.document.getText(selection);
|
const text = textEditor.document.getText(selection);
|
||||||
textList.push(text);
|
textList.push(text);
|
||||||
|
tmp_selectTextLength += text.length;
|
||||||
}
|
}
|
||||||
|
selectTextLength = tmp_selectTextLength;
|
||||||
|
|
||||||
// 更新 _textSelectionLength (用于判断是否展示右键菜单)
|
// 更新 _textSelectionLength (用于判断是否展示右键菜单)
|
||||||
vscode.commands.executeCommand('setContext', '_textSelectionLength', selectTextLength);
|
vscode.commands.executeCommand('setContext', '_textSelectionLength', selectTextLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user