Skip to content

Commit

Permalink
fix(extension): fix code lens
Browse files Browse the repository at this point in the history
  • Loading branch information
clabroche committed Feb 25, 2024
1 parent dcb1b24 commit d17b922
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
3 changes: 2 additions & 1 deletion modules/vscode/backend/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ const routes = (stackMonitor) => {
&& fs.existsSync(pathfs.resolve(a.toString(), './package.json'))
))
.map((path) => fse.readJSONSync(pathfs.resolve(path?.toString() || '', './package.json')).name);
return dependents.some((packageName) => servicePackageNames.includes(packageName));
return dependents.some((packageName) => servicePackageNames.includes(packageName))
|| servicePackageNames.includes(packageJSON.name);
});
res.json(services);
} else {
Expand Down
32 changes: 13 additions & 19 deletions modules/vscode/extension/src/providers/CodeLensProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,23 @@ module.exports = class CodelensProvider {
* @returns {vscode.CodeLens[] | Thenable<vscode.CodeLens[]>}
*/
provideCodeLenses(document) {
if (vscode.workspace.getConfiguration('codelens-stackmonitor').get('enableCodeLens', true)) {
this.codeLenses = [];
const { line } = vscode.window.activeTextEditor.selection.start;
const range = document.getWordRangeAtPosition(new vscode.Position(line, 0), new RegExp(this.regex));
if (range) {
this.codeLenses.push(new vscode.CodeLens(range));
}
return this.codeLenses;
this.codeLenses = [];
const { line } = vscode.window.activeTextEditor.selection.start;
const range = document.getWordRangeAtPosition(new vscode.Position(line, 0), new RegExp(this.regex));
if (range) {
this.codeLenses.push(new vscode.CodeLens(range));
}
return [];
return this.codeLenses;
}

/** @param {vscode.CodeLens} codeLens */
async resolveCodeLens(codeLens) {
if (vscode.workspace.getConfiguration('codelens-stackmonitor').get('enableCodeLens', true)) {
codeLens.command = {
title: this.message,
tooltip: 'Tooltip provided by sample extension',
command: 'codelens-stackmonitor.codelensAction',
arguments: ['Argument 1', false],
};
return codeLens;
}
return null;
codeLens.command = {
title: this.message,
tooltip: 'Tooltip provided by sample extension',
command: 'codelens-stackmonitor.codelensAction',
arguments: ['Argument 1', false],
};
return codeLens;
}
};

0 comments on commit d17b922

Please sign in to comment.