8000 feat: Add support for customized shortcut order · hummingg/vscode-leetcode@cd4faf5 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd4faf5

Browse files
authored
feat: Add support for customized shortcut order
Add support for customized shortcut order, the same to the order in setting
1 parent d713ad5 commit cd4faf5

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/codelens/CustomCodeLensProvider.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,55 @@ export class CustomCodeLensProvider implements vscode.CodeLensProvider {
4646

4747
const range: vscode.Range = new vscode.Range(codeLensLine, 0, codeLensLine, 0);
4848
const codeLens: vscode.CodeLens[] = [];
49+
// support customized shortcut order
50+
for (let i: number = 0; i < shortcuts.length; i++) {
51+
let title, command, args;
52+
let willPush = true;
53+
switch(shortcuts[i]){
54+
case "submit":
55+
title = "Submit";
56+
command = "leetcode.submitSolution";
57+
args = [document.uri];
58+
break;
59+
case "test":
60+
title = "Test";
61+
command = "leetcode.testSolution";
62+
args = [document.uri];
63+
break;
64+
case "star":
65+
if(!node){
66+
willPush = false;
67+
break;
68+
}
69+
title = node.isFavorite ? "Unstar" : "Star";
70+
command = node.isFavorite ? "leetcode.removeFavorite" : "leetcode.addFavorite";
71+
args = [node];
72+
break;
73+
case "solution":
74+
title = "Solution";
75+
command = "leetcode.showSolution";
76+
args = [document.uri];
77+
break;
78+
case "description":
79+
title = "Description";
80+
command = "leetcode.previewProblem";
81+
args = [document.uri];
82+
break;
83+
default:
84+
willPush = false;
85+
break;
86+
}
87+
if(!willPush){
88+
continue;
89+
}
90+
codeLens.push(new vscode.CodeLens(range< B38F /span>, {
91+
title: title,
92+
command: command,
93+
arguments: args,
94+
}));
95+
}
4996

97+
/*
5098
if (shortcuts.indexOf("submit") >= 0) {
5199
codeLens.push(new vscode.CodeLens(range, {
52100
title: "Submit",
@@ -86,6 +134,7 @@ export class CustomCodeLensProvider implements vscode.CodeLensProvider {
86134
arguments: [document.uri],
87135
}));
88136
}
137+
*/
89138

90139
return codeLens;
91140
}

0 commit comments

Comments
 (0)
0