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

是否展示右键菜单逻辑在 VSCode 插件初始化时也也判断一次

This commit is contained in:
2024-04-04 15:36:06 +08:00
parent e709a41697
commit 704b428d5f

View File

@@ -30,6 +30,18 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand('setContext', '_textSelectionLength', text.length);
});
// 初始(VSCode 插件初始化)时也判断一次 (考虑上次关闭 VSCode 有选区,重新打开后 VSCode 回复选区但用户未重新切换选区的场景)
let editor = vscode.window.activeTextEditor;
if (editor) {
let document = editor.document;
let selection = editor.selection;
// 获取选中的文本
let text = document.getText(selection);
vscode.commands.executeCommand('setContext', '_textSelectionLength', text.length);
} else {
vscode.window.showInformationMessage('editor is undefined');
}
const commands: Array<{ command: string; convertFunction: ConvertFunction }> = [
{ command: 'variable-conversion.toCamelCase', convertFunction: TextConversion.toCamelCase },
{ command: 'variable-conversion.toPascalCase', convertFunction: TextConversion.toPascalCase },