Skip to content

Commit 372b59e

Browse files
authored
Fix code lens issue when plugin name is invalid. Closes #118 (#121)
Closes #118
1 parent 08e1b15 commit 372b59e

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929

3030
- Setting: `devproxytoolkit.versionPreference` renamed to `dev-proxy-toolkit.version`
3131

32+
### Fixed:
33+
34+
- Code Lens: Fixed issue with documentation link shown for plugins with invalid names
35+
3236
## [0.8.0] - 2024-09-06
3337

3438
### Changed:

src/codelens.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from 'vscode';
22
import { isConfigFile, getASTNode, getRangeFromASTNode } from './helpers';
33
import parse from 'json-to-ast';
4+
import { pluginSnippets } from './constants';
45

56
export const registerCodeLens = (context: vscode.ExtensionContext) => {
67
context.subscriptions.push(
@@ -49,13 +50,17 @@ export const createCodeLensForPluginNodes = (document: vscode.TextDocument) => {
4950
const pluginName = (pluginNameNode?.value as parse.LiteralNode)
5051
.value as string;
5152

52-
codeLens.push(
53-
new vscode.CodeLens(getRangeFromASTNode(pluginNameNode), {
54-
title: `📄 ${pluginName}`,
55-
command: 'dev-proxy-toolkit.openPluginDoc',
56-
arguments: [pluginName],
57-
})
58-
);
53+
const isValidName = pluginSnippets[pluginName];
54+
55+
if (isValidName) {
56+
codeLens.push(
57+
new vscode.CodeLens(getRangeFromASTNode(pluginNameNode), {
58+
title: `📄 ${pluginName}`,
59+
command: 'dev-proxy-toolkit.openPluginDoc',
60+
arguments: [pluginName],
61+
})
62+
);
63+
}
5964
});
6065
}
6166
}

0 commit comments

Comments
 (0)