From 397777322608ffedeba6a9057e0cb244e59e0fae Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Sun, 23 Feb 2020 13:24:33 +0800 Subject: [PATCH] Remove the deprecated setting: leetcode.enableShortcuts --- README.md | 1 - docs/README_zh-CN.md | 1 - package.json | 6 ------ src/codelens/CodeLensController.ts | 22 +++------------------- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 454a2d46..b5067515 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,6 @@ Thanks for [@yihong0618](https://github.com/yihong0618) provided a workaround wh | `leetcode.filePath` | Specify the relative path under the workspace and the file name to save the problem files. More details can be found [here](https://github.com/jdneo/vscode-leetcode/wiki/Customize-the-Relative-Folder-and-the-File-Name-of-the-Problem-File). | | | **[Deprecated] Use `leetcode.filePath` instead** ~~`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: For example: `problem-${tag}-${difficulty}`~~ | ~~N/A~~ | | `leetcode.enableStatusBar` | Specify whether the LeetCode status bar will be shown or not. | `true` | -| **[Deprecated] Use `leetcode.editor.shortcuts` instead** ~~`leetcode.enableShortcuts`~~ | ~~Specify whether the submit and test shortcuts in editor or not.~~ | ~~`true`~~ | | `leetcode.editor.shortcuts` | Specify the customized shorcuts in editors. Supported values are: `submit`, `test`, `solution` and `description`. | `["submit, test"]` | | `leetcode.enableSideMode` | Specify whether `preview`, `solution` and `submission` tab should be grouped into the second editor column when solving a problem. | `true` | | `leetcode.nodePath` | Specify the `Node.js` executable path. for example, C:\Program Files\nodejs\node.exe | `node` | diff --git a/docs/README_zh-CN.md b/docs/README_zh-CN.md index d6b3b8f4..d69c62a7 100644 --- a/docs/README_zh-CN.md +++ b/docs/README_zh-CN.md @@ -130,7 +130,6 @@ | `leetcode.filePath` | 指定生成题目文件的相对文件夹路径名和文件名。点击查看[更多详细用法](https://github.com/jdneo/vscode-leetcode/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E9%A2%98%E7%9B%AE%E6%96%87%E4%BB%B6%E7%9A%84%E7%9B%B8%E5%AF%B9%E6%96%87%E4%BB%B6%E5%A4%B9%E8%B7%AF%E5%BE%84%E5%92%8C%E6%96%87%E4%BB%B6%E5%90%8D)。 | | | **[Deprecated] 请使用 `leetcode.filePath`** ~~`leetcode.outputFolder`~~ | ~~指定保存文件时所用的相对文件夹路径。除了用户自定义路径外,也可以使用保留项,包括:例如:`problem-${tag}-${difficulty}`~~ | ~~N/A~~ | | `leetcode.enableStatusBar` | 指定是否在 VS Code 下方显示插件状态栏。 | `true` | -| **[Deprecated] 请使用 `leetcode.editor.shortcuts`** ~~`leetcode.enableShortcuts`~~ | ~~指定是否在 VS Code 编辑文件下方显示提交和测试的快捷按钮。~~ | ~~`true`~~ | | `leetcode.editor.shortcuts` | 指定在编辑器内所自定义的快捷方式。可用的快捷方式有: `submit`, `test`, `solution`, `description`。 | `["submit, test"]` | | `leetcode.enableSideMode` | 指定在解决一道题时,是否将`问题预览`、`高票答案`与`提交结果`窗口集中在编辑器的第二栏。 | `true` | | `leetcode.nodePath` | 指定 `Node.js` 可执行文件的路径。如:C:\Program Files\nodejs\node.exe | `node` | diff --git a/package.json b/package.json index 6397ef3a..cc7b9eb1 100644 --- a/package.json +++ b/package.json @@ -621,12 +621,6 @@ "scope": "application", "description": "Show the LeetCode status bar or not." }, - "leetcode.enableShortcuts": { - "type": "boolean", - "default": true, - "scope": "application", - "description": "[Deprecated] Show the submit and test shortcuts in editor or not." - }, "leetcode.editor.shortcuts": { "type": "array", "default": [ diff --git a/src/codelens/CodeLensController.ts b/src/codelens/CodeLensController.ts index 9373df27..8e2fa3c9 100644 --- a/src/codelens/CodeLensController.ts +++ b/src/codelens/CodeLensController.ts @@ -1,7 +1,7 @@ // Copyright (c) jdneo. All rights reserved. // Licensed under the MIT license. -import { ConfigurationChangeEvent, Disposable, languages, workspace, WorkspaceConfiguration } from "vscode"; +import { ConfigurationChangeEvent, Disposable, languages, workspace } from "vscode"; import { CustomCodeLensProvider } from "./CustomCodeLensProvider"; class CodeLensController implements Disposable { @@ -13,14 +13,12 @@ class CodeLensController implements Disposable { this.internalProvider = new CustomCodeLensProvider(); this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => { - if (event.affectsConfiguration("leetcode.enableShortcuts")) { - this.setCodeLensVisibility(); - } else if (event.affectsConfiguration("leetcode.editor.shortcuts")) { + if (event.affectsConfiguration("leetcode.editor.shortcuts")) { this.internalProvider.refresh(); } }, this); - this.setCodeLensVisibility(); + this.registeredProvider = languages.registerCodeLensProvider({ scheme: "file" }, this.internalProvider); } public dispose(): void { @@ -29,20 +27,6 @@ class CodeLensController implements Disposable { } 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("leetcode.enableShortcuts", true); - } } export const codeLensController: CodeLensController = new CodeLensController();