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

Can config whether to show or hide the codelens#273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jdneo merged 1 commit intomasterfromcs/codelens
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,7 +93,9 @@
<img src="https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/imgs/submit.png" alt="Submit the Answer" />
</p>

- You can submit the answer by clicking `🙏 Submit to LeetCode` at the bottom of the file. Or you can trigger the command: **LeetCode: Submit to LeetCode** to submit the **active** file as the answer.
- You can submit the answer by clicking `Submit` at the bottom of the file. Or you can right click in the editor and select `Submit to LeetCode`.

> If you want to hide the shortcuts showing in the editor, just simply set the setting `leetcode.enableShortcuts` to false.

---

Expand All@@ -102,7 +104,7 @@
<img src="https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/imgs/test.png" alt="Test the Answer" />
</p>

-To **test** your answer, right click in the editor and select `Test in LeetCode`.
-You cantest the answer by clicking `Test` at the bottom of the file. Or you can right click in the editor and select `Test in LeetCode`.

- There are 3 ways to test the answer:
- **Test with the default cases**
Expand DownExpand Up@@ -138,6 +140,7 @@
| `leetcode.endpoint` | Specify the active endpoint. Supported endpoints are: `leetcode`, `leetcode-cn` | `leetcode` |
| `leetcode.outputFolder`| Specify the relative path to save the problem files. Besides using customized path, there are also several reserved words which can be used here: <ul><li>`${tag}`: Categorize the problem according to their tags.<li>`${language}`: Categorize the problem according to their language.</li><li>`${difficulty}`: Categorize the problem according to their difficulty.</li></ul> | N/A |
| `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` |
| `leetcode.enableShortcuts` | Specify whether the submit and test shortcuts in editor or not. | `true` |
| `leetcode.nodePath` | Specify the `Node.js` executable path. | `node` |

## Troubleshooting
Expand Down
7 changes: 5 additions & 2 deletionsdocs/README_zh-CN.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,7 +93,9 @@
<img src="https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/imgs/submit.png" alt="提交答案" />
</p>

- 通过点击文件最下方的 `🙏 Submit to LeetCode` 可提交答案。 你也可以触发 **LeetCode: Submit to LeetCode** 命令将**当前**文件作为答案进行提交。
- 通过点击文件最下方的 `Submit` 可提交答案。 你也可以在编辑区内右键并选择 `Submit to LeetCode`,将**当前**文件提交。

> 如果你不希望在编辑器中显示**测试**和**提交**的快捷方式,可以将配置项 `leetcode.enableShortcuts` 设置为 `false`。

---

Expand All@@ -102,7 +104,7 @@
<img src="https://raw.githubusercontent.com/jdneo/vscode-leetcode/master/docs/imgs/test.png" alt="测试答案" />
</p>

-在编辑区内右键并选择 `Testin LeetCode`,可对**当前**答案进行测试
-通过点击文件最下方的 `Test` 可测试答案。你也可以在编辑区内右键并选择 `Testin LeetCode`,**当前**文件进行测试

- 有下列三种测试集来源:
- **默认测试集**:Test with the default cases
Expand DownExpand Up@@ -138,6 +140,7 @@
| `leetcode.endpoint` | 指定使用的终端,可用终端有:`leetcode`, `leetcode-cn` | `leetcode` |
| `leetcode.outputFolder` | 指定保存文件时所用的相对文件夹路径。除了用户自定义路径外,也可以使用保留项,包括:<ul><li>`${tag}`: 根据题目的类别进行分类。<li>`${language}`: 根据题目的语言进行分类。</li><li>`${difficulty}`: 根据题目的难度进行分类。</li></ul> | N/A |
| `leetcode.enableStatusBar` | 指定是否在 VS Code 下方显示插件状态栏。 | `true` |
| `leetcode.enableShortcuts` | 指定是否在 VS Code 编辑文件下方显示提交和测试的快捷按钮。 | `true` |
| `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。 | `node` |

## 疑难解答
Expand Down
6 changes: 6 additions & 0 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -295,6 +295,12 @@
"scope": "application",
"description": "Show the LeetCode status bar or not."
},
"leetcode.enableShortcuts": {
"type": "boolean",
"default": true,
"scope": "application",
"description": "Show the submit and test shortcuts in editor or not."
},
"leetcode.nodePath": {
"type": "string",
"default": "node",
Expand Down
46 changes: 46 additions & 0 deletionssrc/codelens/CodeLensController.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
// Copyright (c) jdneo. All rights reserved.
// Licensed under the MIT license.

import { ConfigurationChangeEvent, Disposable, languages, workspace, WorkspaceConfiguration } from "vscode";
import { CustomCodeLensProvider } from "./CustomCodeLensProvider";

class CodeLensController implements Disposable {
private internalProvider: CustomCodeLensProvider;
private registeredProvider: Disposable | undefined;
private configurationChangeListener: Disposable;

constructor() {
this.internalProvider = new CustomCodeLensProvider();

this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
if (event.affectsConfiguration("leetcode.enableShortcuts")) {
this.setCodeLensVisibility();
}
}, this);

this.setCodeLensVisibility();
}

public dispose(): void {
if (this.registeredProvider) {
this.registeredProvider.dispose();
}
this.configurationChangeListener.dispose();
}

private setCodeLensVisibility(): void {
if (this.isShortcutsEnabled() && !this.registeredProvider) {
this.registeredProvider = languages.registerCodeLensProvider({ scheme: "file" }, this.internalProvider);
} else if (!this.isShortcutsEnabled() && this.registeredProvider) {
this.registeredProvider.dispose();
this.registeredProvider = undefined;
}
}

private isShortcutsEnabled(): boolean {
const configuration: WorkspaceConfiguration = workspace.getConfiguration();
return configuration.get<boolean>("leetcode.enableShortcuts", true);
}
}

export const codeLensController: CodeLensController = new CodeLensController();
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@

import * as vscode from "vscode";

classCodeLensProvider implements vscode.CodeLensProvider {
exportclassCustomCodeLensProvider implements vscode.CodeLensProvider {

private validFileNamePattern: RegExp = /\d+\..*\.(.+)/;

Expand All@@ -16,13 +16,15 @@ class CodeLensProvider implements vscode.CodeLensProvider {

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];
return [
new vscode.CodeLens(range, {
title: "Submit",
command: "leetcode.submitSolution",
}),
new vscode.CodeLens(range, {
title: "Test",
command: "leetcode.testSolution",
}),
];
}
}

export const codeLensProvider: CodeLensProvider = new CodeLensProvider();
4 changes: 2 additions & 2 deletionssrc/extension.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,7 @@
// Licensed under the MIT license.

import * as vscode from "vscode";
import {codeLensProvider } from "./codeLensProvider";
import {codeLensController } from "./codelens/CodeLensController";
import * as cache from "./commands/cache";
import { switchDefaultLanguage } from "./commands/language";
import * as plugin from "./commands/plugin";
Expand DownExpand Up@@ -43,8 +43,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
leetCodeSolutionProvider,
leetCodeExecutor,
markdownEngine,
codeLensController,
vscode.window.createTreeView("leetCodeExplorer", { treeDataProvider: leetCodeTreeDataProvider, showCollapseAll: true }),
vscode.languages.registerCodeLensProvider({ scheme: "file" }, codeLensProvider),
vscode.commands.registerCommand("leetcode.deleteCache", () => cache.deleteCache()),
vscode.commands.registerCommand("leetcode.toggleLeetCodeCn", () => plugin.switchEndpoint()),
vscode.commands.registerCommand("leetcode.signin", () => leetCodeManager.signIn()),
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp