Skip to content

Commit

Permalink
fix: ensure we are on the correct file before displaying gutter icons…
Browse files Browse the repository at this point in the history
… in the active editor
  • Loading branch information
hverlin committed Jan 26, 2025
1 parent 15713f5 commit 3e7b086
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
32 changes: 24 additions & 8 deletions src/providers/inlineToolDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export async function showToolVersionInline(
document: vscode.TextDocument,
miseService: MiseService,
): Promise<void> {
const currentFile = expandPath(document.uri.fsPath);

const [files, tools] = await Promise.all([
miseService.getCurrentConfigFiles(),
miseService.getCurrentTools({ useCache: false }),
]);
const currentFile = expandPath(document.uri.fsPath);
if (!files.includes(currentFile)) {
return;
}
Expand Down Expand Up @@ -82,6 +81,18 @@ export async function showToolVersionInline(
after: { color: "rgba(136,136,136,0.63)" },
});

const activeTextEditor = vscode.window.activeTextEditor;
if (!activeTextEditor) {
return;
}

const currentFileInActiveEditor = expandPath(
activeTextEditor?.document.uri.fsPath,
);
if (currentFile !== currentFileInActiveEditor) {
return;
}

vscode.window.activeTextEditor?.setDecorations(
// @ts-ignore
activeDecorationsPerFileAndTool[currentFile][cleanedToolName],
Expand Down Expand Up @@ -115,14 +126,13 @@ export async function showToolVersionInline(
export async function showOutdatedToolsGutterIcons(
document: vscode.TextDocument,
miseService: MiseService,
context: vscode.ExtensionContext,
): Promise<void> {
const currentFile = expandPath(document.uri.fsPath);

const [files, outdatedTools] = await Promise.all([
miseService.getCurrentConfigFiles(),
miseService.getOutdatedTools(),
]);

const currentFile = expandPath(document.uri.fsPath);
if (!files.includes(currentFile)) {
return;
}
Expand Down Expand Up @@ -179,6 +189,13 @@ export async function showOutdatedToolsGutterIcons(
return;
}

const currentFileInActiveEditor = expandPath(
activeTextEditor?.document.uri.fsPath,
);
if (currentFile !== currentFileInActiveEditor) {
return;
}

const gutterIconPath = vscode.Uri.parse(
getSvgIcon(
vscode.window.activeColorTheme.kind,
Expand Down Expand Up @@ -228,9 +245,8 @@ export async function addToolInfoToEditor(
}

if (shouldShowOutdatedToolGutterDecorations()) {
showOutdatedToolsGutterIcons(document, miseService, context).catch(
(error) =>
logger.info("Error while showing outdated tools gutter icons", error),
showOutdatedToolsGutterIcons(document, miseService).catch((error) =>
logger.info("Error while showing outdated tools gutter icons", error),
);
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/supportedExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const SUPPORTED_EXTENSIONS: Array<ConfigurableExtension> = [
generateConfiguration: async ({
tool,
miseConfig,
useShims,
miseService,
useSymLinks,
}) => {
Expand Down

0 comments on commit 3e7b086

Please sign in to comment.