дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
fix(workbench): Reset project state when a window switches projects
Opening another project in the same window left the previous project's state in module-level stores: Amend and the commit message carried over, debug sessions kept running, and Git Log, usages, hierarchy, inspection, HTTP client, recent locations, navigation history and notifications still showed the old project. Reset each of them on a project root change, stop the old debug sessions, ask about unsaved changes before leaving a project, close the settings window (it would apply to the new project) and end the indexing task when a scan is cancelled.
Цей коміт міститься в:
1 джерело
9a2025b76e
коміт
5f6e2a9c85
30 files changed
+216
-26
No files matched your search
@@ -45,6 +45,17 @@ export const useHierarchy = create<HierarchyState>(() => ({
|
||||
generation: 0,
|
||||
}));
|
||||
|
||||
/** The window switched projects: the tree refers to the previous one's documents. */
|
||||
export function resetHierarchy() {
|
||||
useHierarchy.setState((s) => ({
|
||||
root: null,
|
||||
children: new Map(),
|
||||
failed: new Set(),
|
||||
loading: false,
|
||||
generation: s.generation + 1,
|
||||
}));
|
||||
}
|
||||
|
||||
export function directionLabel(mode: HierarchyMode, direction: HierarchyDirection): string {
|
||||
if (mode === "call") return direction === "incoming" ? "Callers" : "Callees";
|
||||
return direction === "incoming" ? "Supertypes" : "Subtypes";
|
||||
|
||||
@@ -11,9 +11,9 @@ import { installProblemDecorations } from "./decorations";
|
||||
import { ProblemsHeaderActions, ProblemsTabs, ProblemsView } from "./ProblemsView";
|
||||
import { UsagesTabs, UsagesView } from "./UsagesView";
|
||||
import { UsagesPopup } from "./UsagesPopup";
|
||||
import { findUsages, showUsageResults, showUsagesPopup } from "./usages";
|
||||
import { findUsages, resetUsages, showUsageResults, showUsagesPopup } from "./usages";
|
||||
import { HierarchyTabs, HierarchyView } from "./HierarchyView";
|
||||
import { showHierarchy } from "./hierarchy";
|
||||
import { resetHierarchy, showHierarchy } from "./hierarchy";
|
||||
import { installServerEvents } from "./servers";
|
||||
import { ServerStatus } from "./ServerStatus";
|
||||
|
||||
@@ -35,6 +35,8 @@ export function activate(): () => void {
|
||||
if (r !== root) {
|
||||
root = r;
|
||||
clearProblems();
|
||||
resetUsages();
|
||||
resetHierarchy();
|
||||
}
|
||||
});
|
||||
const disposers = [
|
||||
|
||||
@@ -126,6 +126,12 @@ export async function fetchUsages(c: CaretContext): Promise<FetchedUsages> {
|
||||
return { groups: groupUsages(locs, files), note };
|
||||
}
|
||||
|
||||
/** The window switched projects: results (and in-flight searches) of the previous one are dropped. */
|
||||
export function resetUsages() {
|
||||
useUsages.setState({ search: null });
|
||||
useUsagesPopup.setState({ open: false, symbol: null, groups: [], note: null });
|
||||
}
|
||||
|
||||
export async function findUsages() {
|
||||
const c = caretContext();
|
||||
if (!c) {
|
||||
|
||||
Reference in new issue
Заблокувати користувача