Skip to content

Commit

Permalink
refactor: change commands name
Browse files Browse the repository at this point in the history
  • Loading branch information
zjffun committed Oct 26, 2024
1 parent c070be8 commit d315c6c
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 42 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
"icon": "$(edit)"
},
{
"command": "_snippetsmanager.showSnippet",
"title": "%extension.showSnippet.title%",
"command": "_snippetsmanager.viewSnippet",
"title": "%extension.viewSnippet.title%",
"icon": "$(book)"
},
{
Expand Down Expand Up @@ -139,14 +139,14 @@
"category": "Snippets Manager"
},
{
"command": "snippetsmanager.showSource",
"title": "%extension.showSource.title%",
"command": "snippetsmanager.openSource",
"title": "%extension.openSource.title%",
"category": "Snippets Manager",
"icon": "$(go-to-file)"
},
{
"command": "snippetsmanager.showEditor",
"title": "%extension.showEditor.title%",
"command": "snippetsmanager.openEditor",
"title": "%extension.openEditor.title%",
"category": "Snippets Manager",
"icon": "$(book)"
}
Expand Down Expand Up @@ -183,7 +183,7 @@
"menus": {
"editor/title": [
{
"command": "snippetsmanager.showEditor",
"command": "snippetsmanager.openEditor",
"when": "resourceExtname == '.code-snippets'",
"group": "navigation"
}
Expand Down Expand Up @@ -252,7 +252,7 @@
"group": "snippets@2"
},
{
"command": "_snippetsmanager.showSnippet",
"command": "_snippetsmanager.viewSnippet",
"when": "viewItem == snippetsmanager-snippetsView-Explorer-FileItem && !listMultiSelection",
"group": "inline@1"
},
Expand All @@ -269,11 +269,11 @@
],
"commandPalette": [
{
"command": "snippetsmanager.showSource",
"command": "snippetsmanager.openSource",
"when": "resourceExtname == '.code-snippets'"
},
{
"command": "snippetsmanager.showEditor",
"command": "snippetsmanager.openEditor",
"when": "resourceExtname == '.code-snippets'"
},
{
Expand All @@ -289,7 +289,7 @@
"when": "false"
},
{
"command": "_snippetsmanager.showSnippet",
"command": "_snippetsmanager.viewSnippet",
"when": "false"
},
{
Expand Down
6 changes: 3 additions & 3 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"extension.deleteSnippet.title": "Delete Snippet(s)",
"extension.editSnippet.title": "Edit Snippet",
"extension.duplicateSnippet.title": "Duplicate Snippet",
"extension.showSnippet.title": "Show Snippet",
"extension.viewSnippet.title": "View Snippet",
"extension.deleteSnippetFile.title": "Delete Snippet File",
"extension.refresh.title": "Refresh",
"extension.search.title": "Search Workspace, User and Extension Snippets",
"extension.searchWorkspaceSnippets.title": "Search Workspace Snippets",
"extension.searchUserSnippets.title": "Search User Snippets",
"extension.searchExtensionSnippets.title": "Search Extension Snippets",
"extension.showSource.title": "Show Source",
"extension.showEditor.title": "Show Editor",
"extension.openSource.title": "Open Source",
"extension.openEditor.title": "Open Editor",
"extension.codeSnippetsEditorView.displayName": "Code Snippets Editor",
"extension.configuration.title": "Snippets Manager",
"extension.configuration.autoCloseSnippetBodyEditor.desc": "Controls whether to automatically close the code snippet body editor after saving."
Expand Down
6 changes: 3 additions & 3 deletions package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"extension.deleteSnippet.title": "删除代码片段",
"extension.editSnippet.title": "编辑代码片段",
"extension.duplicateSnippet.title": "制作代码片段副本",
"extension.showSnippet.title": "查看代码片段",
"extension.viewSnippet.title": "查看代码片段",
"extension.deleteSnippetFile.title": "删除代码片段文件",
"extension.refresh.title": "刷新",
"extension.search.title": "搜索工作区、用户和拓展程序的代码片段",
"extension.searchWorkspaceSnippets.title": "搜索工作区的代码片段",
"extension.searchUserSnippets.title": "搜索用户的代码片段",
"extension.searchExtensionSnippets.title": "搜索拓展程序的代码片段",
"extension.showSource.title": "打开源文件",
"extension.showEditor.title": "打开代码片段编辑器",
"extension.openSource.title": "打开源文件",
"extension.openEditor.title": "打开代码片段编辑器",
"extension.codeSnippetsEditorView.displayName": "代码片段编辑器",
"extension.configuration.title": "代码片段管理",
"extension.configuration.autoCloseSnippetBodyEditor.desc": "控制是否保存后自动关闭代码片段主体编辑器。"
Expand Down
6 changes: 3 additions & 3 deletions src/CodeSnippetsEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Buffer } from "buffer";
import * as vscode from "vscode";
import { CodeSnippetsService } from "./CodeSnippetsService";
import editSnippetBody from "./commands/editSnippetBody";
import showSource from "./commands/showSource";
import openSource from "./commands/openSource";
import { no, yes } from "./common/l10n";
import { getNonce } from "./util";
import logger from "./utils/logger";
Expand Down Expand Up @@ -219,7 +219,7 @@ export class CodeSnippetsEditor implements vscode.CustomTextEditorProvider {
}

case "openInDefaultEditor":
showSource();
openSource();
return;

case "help":
Expand Down Expand Up @@ -250,7 +250,7 @@ export class CodeSnippetsEditor implements vscode.CustomTextEditorProvider {
);

if (answer === yes) {
showSource();
openSource();
return;
}
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/commands/searchSnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default async (type?: SnippetType) => {

if (result) {
vscode.commands.executeCommand(
"_snippetsmanager.showSnippet",
"_snippetsmanager.viewSnippet",
result.snippet,
);
}
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import deleteSnippetFile from "./commands/deleteSnippetFile";
import duplicateSnippet from "./commands/duplicateSnippet";
import editSnippet from "./commands/editSnippet";
import { initEditSnippetBody } from "./commands/editSnippetBody";
import openEditor from "./commands/openEditor";
import openSnippetsManger from "./commands/openSnippetsManger";
import openSource from "./commands/openSource";
import pasteSnippet from "./commands/pasteSnippet";
import searchSnippet from "./commands/searchSnippet";
import showEditor from "./commands/showEditor";
import showSnippet from "./commands/showSnippet";
import showSource from "./commands/showSource";
import viewSnippet from "./commands/viewSnippet";
import workbenchActionOpenSnippets, {
workbenchActionOpenSnippetsId,
} from "./commands/workbenchActionOpenSnippets";
Expand Down Expand Up @@ -188,9 +188,9 @@ export function activate(context: vscode.ExtensionContext) {

context.subscriptions.push(
vscode.commands.registerCommand(
"_snippetsmanager.showSnippet",
"_snippetsmanager.viewSnippet",
(snippet) => {
showSnippet(snippet);
viewSnippet(snippet);
},
),
);
Expand All @@ -202,14 +202,14 @@ export function activate(context: vscode.ExtensionContext) {
);

context.subscriptions.push(
vscode.commands.registerCommand("snippetsmanager.showSource", async () => {
return showSource();
vscode.commands.registerCommand("snippetsmanager.openSource", async () => {
return openSource();
}),
);

context.subscriptions.push(
vscode.commands.registerCommand("snippetsmanager.showEditor", async () => {
return showEditor();
vscode.commands.registerCommand("snippetsmanager.openEditor", async () => {
return openEditor();
}),
);

Expand Down
16 changes: 8 additions & 8 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ suite("Extension", () => {
const uri = await createTestFile("");

await vscode.commands.executeCommand("vscode.open", uri);
await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);

await vscode.commands.executeCommand("workbench.action.splitEditorRight");
Expand All @@ -82,7 +82,7 @@ suite("Extension", () => {
assert.strictEqual(currentWebviewPanel, null);

await vscode.commands.executeCommand("vscode.open", uri);
await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);
});

Expand All @@ -96,24 +96,24 @@ suite("Extension", () => {
const uri3 = await createTestFile("");

await vscode.commands.executeCommand("vscode.open", uri);
await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);

await vscode.commands.executeCommand("vscode.open", uri2);
await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);

await vscode.commands.executeCommand("vscode.open", uri3);
assert.ok(!currentWebviewPanel);

await vscode.commands.executeCommand("vscode.open", uri2);
await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);

await vscode.commands.executeCommand("snippetsmanager.showSource");
await vscode.commands.executeCommand("snippetsmanager.openSource");
assert.ok(!currentWebviewPanel);

await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);
});

Expand All @@ -125,7 +125,7 @@ suite("Extension", () => {
const uri = await createTestFile(`[{"test": {}}]`);

await vscode.commands.executeCommand("vscode.open", uri);
await vscode.commands.executeCommand("snippetsmanager.showEditor");
await vscode.commands.executeCommand("snippetsmanager.openEditor");
assert.ok(currentWebviewPanel);
});
});
8 changes: 4 additions & 4 deletions src/views/BasicSnippetsExplorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export default abstract class BasicSnippetsExplorerView
}

public getTreeItem(element: SnippetTreeItem): SnippetTreeItem {
const showSnippetCommand = {
command: "_snippetsmanager.showSnippet",
title: "Show this snippet in editor.",
const viewSnippetCommand = {
command: "_snippetsmanager.viewSnippet",
title: "View this snippet in editor.",
arguments: [element],
};

Expand All @@ -107,7 +107,7 @@ export default abstract class BasicSnippetsExplorerView
element.name || "",
element.children ? vscode.TreeItemCollapsibleState.Collapsed : undefined,
);
item.command = !element.children ? showSnippetCommand : undefined;
item.command = !element.children ? viewSnippetCommand : undefined;
item.contextValue = contextValue;

return item;
Expand Down

0 comments on commit d315c6c

Please sign in to comment.