Skip to content

Commit 8453dba

Browse files
committed
feat(patches): add copy path and copy relative path to context menu
1 parent 51f80c8 commit 8453dba

File tree

2 files changed

+70
-27
lines changed

2 files changed

+70
-27
lines changed

package.json

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,34 @@
126126
"enablement": "electron-build-tools:canChangeConfig"
127127
},
128128
{
129-
"command": "electron-build-tools.openPatch",
129+
"command": "electron-build-tools.patches.copyPath",
130+
"title": "Copy Path",
131+
"category": "Electron Build Tools"
132+
},
133+
{
134+
"command": "electron-build-tools.patches.copyRelativePath",
135+
"title": "Copy Relative Path",
136+
"category": "Electron Build Tools"
137+
},
138+
{
139+
"command": "electron-build-tools.patches.open",
130140
"title": "Open Patch",
131141
"category": "Electron Build Tools"
132142
},
133143
{
134-
"command": "electron-build-tools.refreshPatches",
144+
"command": "electron-build-tools.patches.refresh",
135145
"title": "Refresh Patches",
136146
"category": "Electron Build Tools",
137147
"icon": "$(refresh)",
138148
"enablement": "electron-build-tools:canRefreshPatches"
139149
},
150+
{
151+
"command": "electron-build-tools.patches.search",
152+
"title": "Search Patches",
153+
"category": "Electron Build Tools",
154+
"icon": "$(search)",
155+
"enablement": "electron-build-tools:active"
156+
},
140157
{
141158
"command": "electron-build-tools.removeConfig",
142159
"title": "Remove Config",
@@ -180,13 +197,6 @@
180197
"icon": "$(search)",
181198
"enablement": "electron-build-tools:active"
182199
},
183-
{
184-
"command": "electron-build-tools.searchPatches",
185-
"title": "Search Patches",
186-
"category": "Electron Build Tools",
187-
"icon": "$(search)",
188-
"enablement": "electron-build-tools:active"
189-
},
190200
{
191201
"command": "electron-build-tools.showPatchesDocs",
192202
"title": "Show Patches Documentation",
@@ -680,15 +690,27 @@
680690
"when": "electron-build-tools:build-tools-installed"
681691
},
682692
{
683-
"command": "electron-build-tools.openPatch",
693+
"command": "electron-build-tools.patches.copyPath",
684694
"when": "false"
685695
},
686696
{
687-
"command": "electron-build-tools.removeConfig",
697+
"command": "electron-build-tools.patches.copyRelativePath",
698+
"when": "false"
699+
},
700+
{
701+
"command": "electron-build-tools.patches.open",
688702
"when": "false"
689703
},
690704
{
691-
"command": "electron-build-tools.refreshPatches",
705+
"command": "electron-build-tools.patches.refresh",
706+
"when": "false"
707+
},
708+
{
709+
"command": "electron-build-tools.patches.search",
710+
"when": "electron-build-tools:active"
711+
},
712+
{
713+
"command": "electron-build-tools.removeConfig",
692714
"when": "false"
693715
},
694716
{
@@ -715,10 +737,6 @@
715737
"command": "electron-build-tools.searchDocs",
716738
"when": "electron-build-tools:active"
717739
},
718-
{
719-
"command": "electron-build-tools.searchPatches",
720-
"when": "electron-build-tools:active"
721-
},
722740
{
723741
"command": "electron-build-tools.showPatchesDocs",
724742
"when": "false"
@@ -789,11 +807,22 @@
789807
],
790808
"view/item/context": [
791809
{
792-
"command": "electron-build-tools.openPatch",
793-
"when": "view == electron-build-tools:patches && viewItem == patch"
810+
"command": "electron-build-tools.patches.copyPath",
811+
"when": "view == electron-build-tools:patches && viewItem == patch",
812+
"group": "6_copypath"
794813
},
795814
{
796-
"command": "electron-build-tools.refreshPatches",
815+
"command": "electron-build-tools.patches.copyRelativePath",
816+
"when": "view == electron-build-tools:patches && viewItem == patch",
817+
"group": "6_copypath"
818+
},
819+
{
820+
"command": "electron-build-tools.patches.open",
821+
"when": "view == electron-build-tools:patches && viewItem == patch",
822+
"group": "navigation"
823+
},
824+
{
825+
"command": "electron-build-tools.patches.refresh",
797826
"when": "view == electron-build-tools:patches && viewItem == repo",
798827
"group": "inline"
799828
},
@@ -841,18 +870,18 @@
841870
"group": "navigation"
842871
},
843872
{
844-
"command": "electron-build-tools.refreshPatches",
873+
"command": "electron-build-tools.patches.refresh",
845874
"when": "view == electron-build-tools:patches",
846875
"group": "navigation"
847876
},
848877
{
849-
"command": "electron-build-tools.searchDocs",
850-
"when": "view == electron-build-tools:docs",
878+
"command": "electron-build-tools.patches.search",
879+
"when": "view == electron-build-tools:patches",
851880
"group": "navigation"
852881
},
853882
{
854-
"command": "electron-build-tools.searchPatches",
855-
"when": "view == electron-build-tools:patches",
883+
"command": "electron-build-tools.searchDocs",
884+
"when": "view == electron-build-tools:docs",
856885
"group": "navigation"
857886
},
858887
{

src/commands/patches.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,21 @@ export function registerPatchesCommands(
5050

5151
context.subscriptions.push(
5252
vscode.commands.registerCommand(
53-
`${commandPrefix}.openPatch`,
53+
`${commandPrefix}.patches.copyPath`,
54+
(patchTreeItem: Patch) => {
55+
return vscode.env.clipboard.writeText(patchTreeItem.resourceUri.fsPath);
56+
},
57+
),
58+
vscode.commands.registerCommand(
59+
`${commandPrefix}.patches.copyRelativePath`,
60+
(patchTreeItem: Patch) => {
61+
return vscode.env.clipboard.writeText(
62+
path.relative(electronRoot.path, patchTreeItem.resourceUri.path),
63+
);
64+
},
65+
),
66+
vscode.commands.registerCommand(
67+
`${commandPrefix}.patches.open`,
5468
(patchTreeItem: Patch) => {
5569
let uri = patchTreeItem.resourceUri;
5670

@@ -70,7 +84,7 @@ export function registerPatchesCommands(
7084
),
7185
ExtensionState.registerExtensionOperationCommand(
7286
ExtensionOperation.REFRESH_PATCHES,
73-
`${commandPrefix}.refreshPatches`,
87+
`${commandPrefix}.patches.refresh`,
7488
() => {
7589
vscode.window.showErrorMessage(
7690
"Can't refresh patches, other work in-progress",
@@ -104,7 +118,7 @@ export function registerPatchesCommands(
104118
},
105119
),
106120
vscode.commands.registerCommand(
107-
`${commandPrefix}.searchPatches`,
121+
`${commandPrefix}.patches.search`,
108122
async () => {
109123
const patchesConfig = parsePatchConfig(
110124
getPatchesConfigFile(electronRoot),

0 commit comments

Comments
 (0)