Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f48e94

Browse files
committed
Add Code Lens for submitting the answer
1 parentb68b352 commit1f48e94

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎src/codeLensProvider.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) jdneo. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
import*asvscodefrom"vscode";
5+
6+
classCodeLensProviderimplementsvscode.CodeLensProvider{
7+
8+
privatevalidFileNamePattern:RegExp=/\d+\..*\.(.+)/;
9+
10+
publicprovideCodeLenses(document:vscode.TextDocument):vscode.ProviderResult<vscode.CodeLens[]>{
11+
constfileName:string=document.fileName.trim();
12+
constmatchResult:RegExpMatchArray|null=fileName.match(this.validFileNamePattern);
13+
if(!matchResult){
14+
returnundefined;
15+
}
16+
17+
constrange:vscode.Range=newvscode.Range(document.lineCount-1,0,document.lineCount-1,0);
18+
19+
constlens:vscode.CodeLens=newvscode.CodeLens(range,{
20+
title:"🙏 Submit to LeetCode",
21+
command:"leetcode.submitSolution",
22+
});
23+
24+
return[lens];
25+
}
26+
}
27+
28+
exportconstcodeLensProvider:CodeLensProvider=newCodeLensProvider();

‎src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT license.
33

44
import*asvscodefrom"vscode";
5+
import{codeLensProvider}from"./codeLensProvider";
56
import*ascachefrom"./commands/cache";
67
import*aspluginfrom"./commands/plugin";
78
import*assessionfrom"./commands/session";
@@ -25,6 +26,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
2526
leetCodeStatusBarItem,
2627
leetCodeChannel,
2728
vscode.window.registerTreeDataProvider("leetCodeExplorer",leetCodeTreeDataProvider),
29+
vscode.languages.registerCodeLensProvider({scheme:"file"},codeLensProvider),
2830
vscode.commands.registerCommand("leetcode.deleteCache",()=>cache.deleteCache()),
2931
vscode.commands.registerCommand("leetcode.toogleLeetCodeCn",()=>plugin.toogleLeetCodeCn()),
3032
vscode.commands.registerCommand("leetcode.signin",()=>leetCodeManager.signIn()),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp