Skip to content

Commit

Permalink
隐藏不必要的命令
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Apr 2, 2024
1 parent a30c73e commit 1aa3dff
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@
},
{
"command": "y3-helper.deleteEditorTableItem",
"title": "Y3:删除物编项目",
"title": "Y3:删除物编项目(删除后不可恢复)",
"enablement": "view == y3-helper.editorTableView && viewItem == json"
},
{
"command": "y3-helper.renameEditorTableItem",
"title": "Y3:修改物编项目名称",
"title": "Y3:修改物编项目的名称",
"enablement": "view == y3-helper.editorTableView && viewItem == json"
},
{
Expand Down Expand Up @@ -174,7 +174,8 @@
},
{
"command": "y3-helper.openFile",
"title": "Y3:打开文件"
"title": "Y3:打开文件",
"enablement": "view == y3-helper.editorTableView"
},
{
"command": "y3-helper.revealInFileExplorer",
Expand Down
2 changes: 1 addition & 1 deletion src/editorTable/editorTableProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class FileNode extends vscode.TreeItem {
this.resourceUri = resourceUri;
this.isDirectory = isDirectory;
this.command = isDirectory ? undefined : {
command: 'y3-helper.openFile',
command: 'vscode.open',
title: '打开文件',
arguments: [resourceUri]
};
Expand Down
35 changes: 4 additions & 31 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import * as tools from "./tools";
import * as preset from './preset';
import { englishPathToChinese } from './constants';
import * as mainMenu from './mainMenu';
import path from 'path';
import * as fs from 'fs';
import { hash } from './utility';



class Helper {
Expand Down Expand Up @@ -488,35 +487,9 @@ class Helper {
}

private registerCommandOfOpenFile() {
vscode.commands.registerCommand('y3-helper.openFile', async (args: vscode.Uri | FileNode) => {
if (args instanceof vscode.Uri) {
const document = await vscode.workspace.openTextDocument(args.fsPath);
vscode.window.showTextDocument(document);
}
else if (args instanceof FileNode) {
const document = await vscode.workspace.openTextDocument(args.resourceUri.fsPath);
vscode.window.showTextDocument(document);
}
else {

// 如果参数为其他的,就让用户自己选
const openDialogOptions: vscode.OpenDialogOptions = {
canSelectFiles: true,
canSelectFolders: false,
canSelectMany: false,
openLabel: '选择你要打开的文件'
};

// 展示选择文件窗口
vscode.window.showOpenDialog(openDialogOptions).then(async fileUri => {
if (fileUri && fileUri[0]) {
vscode.window.showInformationMessage('打开: ' + fileUri[0].fsPath);
const document = await vscode.workspace.openTextDocument(fileUri[0].fsPath);
vscode.window.showTextDocument(document);
}
});
}

vscode.commands.registerCommand('y3-helper.openFile', async (args:FileNode) => {
const document = await vscode.workspace.openTextDocument(args.resourceUri.fsPath);
vscode.window.showTextDocument(document);
});
}

Expand Down

0 comments on commit 1aa3dff

Please sign in to comment.