Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8817581

Browse files
committed
fix: CodeLens position
1 parent d0f23e5 commit 8817581

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/codelens/CustomCodeLensProvider.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,29 @@ export class CustomCodeLensProvider implements vscode.CodeLensProvider {
2222
return;
2323
}
2424

25+
const fileName: string = document.fileName.trim();
26+
const workspaceFolder: string = vscode.workspace.getConfiguration("leetcode").get("workspaceFolder", "");
27+
28+
if (fileName.indexOf(workspaceFolder) === -1) {
29+
return undefined;
30+
}
31+
2532
const content: string = document.getText();
2633
const matchResult: RegExpMatchArray | null = content.match(/@lc app=.* id=.* lang=.*/);
2734
if (!matchResult) {
2835
return undefined;
2936
}
3037

31-
const range: vscode.Range = new vscode.Range(document.lineCount - 1, 0, document.lineCount - 1, 0);
38+
let codeLensLine: number = content.length - 1;
39+
40+
for (let i: number = 0; i < content.length; ++i) {
41+
if (content[i].indexOf("@lc code=end") >= 0) {
42+
codeLensLine = i;
43+
break;
44+
}
45+
}
46+
47+
const range: vscode.Range = new vscode.Range(codeLensLine, 0, codeLensLine, 0);
3248
const codeLens: vscode.CodeLens[] = [];
3349

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

0 commit comments

Comments
 (0)