Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nhedger committed Jul 27, 2024
1 parent 45a7ba1 commit c886011
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
27 changes: 26 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { error, info } from "./logger";
import { type Project, createProjects } from "./project";
import { createSession } from "./session";
import { state } from "./state";
import { config, hasUntitledDocuments } from "./utils";
import { config, hasUntitledDocuments, supportedLanguages } from "./utils";

/**
* Creates a new Biome extension
Expand Down Expand Up @@ -48,10 +48,35 @@ export const createExtension = async (
return;
}

window.onDidChangeActiveTextEditor((editor) => {
if (!editor) {
state.state = "disabled";
return;
}

if (!supportedLanguages.includes(editor.document.languageId)) {
state.state = "disabled";
return;
}

const project = [...state.sessions.keys()].find((project) =>
editor.document.uri.fsPath.startsWith(project.path),
);

if (project) {
state.activeProject = project;
}
});

state.state = "initializing";

// Start the extension
await start();

// Set the active project, if any
state.activeProject = [...state.sessions.keys()].find((project) =>
window.activeTextEditor?.document.uri.fsPath.startsWith(project.path),
);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { workspace } from "vscode";
import { window, workspace } from "vscode";
import type { Project } from "./project";
import type { Session } from "./session";
import { updateStatusBar } from "./ui/status-bar/status-bar";
Expand Down
2 changes: 1 addition & 1 deletion src/ui/status-bar/status-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const updateStatusBar = () => {
const text = getStateText();
const tooltip = getStateTooltip();

statusBar.item.text = `${icon} ${text}`.trim();
statusBar.item.text = `${icon} ${text} ${state.activeProject?.path}`.trim();
statusBar.item.tooltip = tooltip;
statusBar.item.show();
};
Expand Down
Empty file.

0 comments on commit c886011

Please sign in to comment.