Skip to content

Commit b7ededc

Browse files
magic-akarijdneo
authored andcommitted
fix: CodeLens position (#426)
1 parent ef4bcbd commit b7ededc

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

Diff for: package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,6 @@
683683
"markdown-it": "^8.4.2",
684684
"require-from-string": "^2.0.2",
685685
"unescape-js": "^1.1.1",
686-
"vsc-leetcode-cli": "2.6.10"
686+
"vsc-leetcode-cli": "2.6.11"
687687
}
688688
}

Diff for: src/codelens/CustomCodeLensProvider.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ export class CustomCodeLensProvider implements vscode.CodeLensProvider {
2828
return undefined;
2929
}
3030

31-
const range: vscode.Range = new vscode.Range(document.lineCount - 1, 0, document.lineCount - 1, 0);
31+
let codeLensLine: number = document.lineCount - 1;
32+
for (let i: number = document.lineCount - 1; i >= 0; i--) {
33+
const lineContent: string = document.lineAt(i).text;
34+
if (lineContent.indexOf("@lc code=end") >= 0) {
35+
codeLensLine = i;
36+
break;
37+
}
38+
}
39+
40+
const range: vscode.Range = new vscode.Range(codeLensLine, 0, codeLensLine, 0);
3241
const codeLens: vscode.CodeLens[] = [];
3342

3443
if (shortcuts.indexOf("submit") >= 0) {

0 commit comments

Comments
 (0)