Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/oxlint/src-js/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ export let currentWorkspaceUri: string | null = null;
export function createWorkspace(workspaceUri: string): undefined {
debugAssert(!workspaces.has(workspaceUri), `Workspace "${workspaceUri}" already exists`);

const workspace = {
workspaces.set(workspaceUri, {
cwd: "",
allOptions: [],
rules: [],
};
});

workspaces.set(workspaceUri, workspace);
currentWorkspace = workspace;
currentWorkspaceUri = workspaceUri;
// Set current workspace to `null` to force switching workspace in the next call to `loadPlugin`.
// Otherwise, if the new workspace has same URI as a previous workspace (which it does when reloading a workspace),
// `cwd`, `registeredRules` and `allOptions` will still contain the state from the old version of the workspace.
// This means `registeredRules` does not get replaced with an empty array before loading plugins again.
// Forcing a switch to the new workspace overwrites the stale state.
currentWorkspace = null;
currentWorkspaceUri = null;
}

/**
Expand Down
Loading