-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Code Lens for submitting the answer
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) jdneo. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
import * as vscode from "vscode"; | ||
|
||
class CodeLensProvider implements vscode.CodeLensProvider { | ||
|
||
private validFileNamePattern: RegExp = /\d+\..*\.(.+)/; | ||
|
||
public provideCodeLenses(document: vscode.TextDocument): vscode.ProviderResult<vscode.CodeLens[]> { | ||
const fileName: string = document.fileName.trim(); | ||
const matchResult: RegExpMatchArray | null = fileName.match(this.validFileNamePattern); | ||
if (!matchResult) { | ||
return undefined; | ||
} | ||
|
||
const range: vscode.Range = new vscode.Range(document.lineCount - 1, 0, document.lineCount - 1, 0); | ||
|
||
const lens: vscode.CodeLens = new vscode.CodeLens(range, { | ||
title: "🙏 Submit to LeetCode", | ||
command: "leetcode.submitSolution", | ||
}); | ||
|
||
return [lens]; | ||
} | ||
} | ||
|
||
export const codeLensProvider: CodeLensProvider = new CodeLensProvider(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters