仅当选中了文字后,才显示右键菜单
This commit is contained in:
parent
35f778517e
commit
24223d0423
@ -93,6 +93,7 @@
|
||||
"group": "1_modification@9"
|
||||
},
|
||||
{
|
||||
"when": "editorTextFocus && _textSelectionLength >= 1",
|
||||
"submenu": "extension.stringConversionMenu",
|
||||
"group": "1_modification@9"
|
||||
}
|
||||
|
@ -21,6 +21,12 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
// vscode.window.showInformationMessage('Hello World from text-conversion!');
|
||||
// });
|
||||
|
||||
// 用于判断是否展示右键菜单
|
||||
vscode.window.onDidChangeTextEditorSelection(event => {
|
||||
const text = event.textEditor.document.getText(event.selections[0]);
|
||||
vscode.commands.executeCommand('setContext', '_textSelectionLength', text.length);
|
||||
});
|
||||
|
||||
const handleEditorReplace = (convertFunction: ConvertFunction) => {
|
||||
// 获取当前编辑器
|
||||
let editor = vscode.window.activeTextEditor;
|
||||
|
Loading…
Reference in New Issue
Block a user