Skip to content

Commit

Permalink
feat(codelens): Don't add target names for one line targets (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
romannikov authored Jul 4, 2024
1 parent da62c67 commit 4f02dc5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/codelens/bazel_build_code_lens_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ export class BazelBuildCodeLensProvider implements vscode.CodeLensProvider {
name: string;
}

const useTargetMap = queryResult.target
.map((t) => new QueryLocation(t.rule.location).line)
.reduce((countMap, line) => {
countMap.set(line, countMap.has(line));
return countMap;
}, new Map<number, boolean>());
for (const target of queryResult.target) {
const location = new QueryLocation(target.rule.location);
const targetName = target.rule.name;
Expand Down Expand Up @@ -172,15 +178,16 @@ export class BazelBuildCodeLensProvider implements vscode.CodeLensProvider {
}

for (const command of commands) {
const title = `${command.name} ${targetShortName}`;
const tooltip = `${command.name} ${targetShortName}`;
const title = useTargetMap.get(location.line) ? tooltip : command.name;
result.push(
new vscode.CodeLens(location.range, {
arguments: [
new CodeLensCommandAdapter(bazelWorkspaceInfo, [targetName]),
],
command: command.commandString,
title,
tooltip: title,
tooltip,
}),
);
}
Expand Down

0 comments on commit 4f02dc5

Please sign in to comment.