дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15: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
@@ -49,14 +49,16 @@ interface DuplicatesState {
|
||||
last: { choice: ScopeChoice; options: DuplicateOptions } | null;
|
||||
}
|
||||
|
||||
export const useDuplicates = create<DuplicatesState>(() => ({
|
||||
const initialDuplicates = (): DuplicatesState => ({
|
||||
running: false,
|
||||
report: null,
|
||||
scopeLabel: null,
|
||||
error: null,
|
||||
selected: null,
|
||||
last: null,
|
||||
}));
|
||||
});
|
||||
|
||||
export const useDuplicates = create<DuplicatesState>(initialDuplicates);
|
||||
|
||||
let inflight: RequestId | null = null;
|
||||
|
||||
@@ -64,6 +66,13 @@ export function cancelDuplicates() {
|
||||
if (inflight !== null) void commands.cancelRequest(inflight).catch(() => undefined);
|
||||
}
|
||||
|
||||
/** The window switched projects: stops the run and forgets its report. */
|
||||
export function resetDuplicates() {
|
||||
cancelDuplicates();
|
||||
inflight = null;
|
||||
useDuplicates.setState(initialDuplicates());
|
||||
}
|
||||
|
||||
export async function locateDuplicates(choice: ScopeChoice, options: DuplicateOptions): Promise<void> {
|
||||
const scope = await resolveScope(choice);
|
||||
if (typeof scope === "string") {
|
||||
|
||||
@@ -3,14 +3,22 @@
|
||||
* Duplicates and Search / Replace Structurally.
|
||||
*/
|
||||
import { registerActions } from "@/platform/actions";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { registerOverlay, registerToolWindow } from "@/workbench/contributions";
|
||||
import { showDuplicatesDialog, showInspectCodeDialog, showStructuralDialog } from "./AnalysisDialogs";
|
||||
import { AnalysisDialogHost } from "./dialogs";
|
||||
import { resetDuplicates } from "./duplicates";
|
||||
import { DuplicatesHeaderActions, DuplicatesView } from "./DuplicatesView";
|
||||
import { resetInspection } from "./inspect";
|
||||
import { InspectionHeaderActions, InspectionView } from "./InspectionView";
|
||||
|
||||
export function activate(): () => void {
|
||||
const disposers = [
|
||||
useProject.subscribe((s, prev) => {
|
||||
if (s.project?.root === prev.project?.root) return;
|
||||
resetInspection();
|
||||
resetDuplicates();
|
||||
}),
|
||||
registerOverlay({ id: "analysis.dialogs", component: AnalysisDialogHost }),
|
||||
registerToolWindow({
|
||||
id: "inspection",
|
||||
|
||||
@@ -101,7 +101,7 @@ interface InspectState {
|
||||
last: ScopeChoice | null;
|
||||
}
|
||||
|
||||
export const useInspection = create<InspectState>(() => ({
|
||||
const initialInspection = (): InspectState => ({
|
||||
running: false,
|
||||
total: 0,
|
||||
done: 0,
|
||||
@@ -110,7 +110,9 @@ export const useInspection = create<InspectState>(() => ({
|
||||
scopeLabel: null,
|
||||
error: null,
|
||||
last: null,
|
||||
}));
|
||||
});
|
||||
|
||||
export const useInspection = create<InspectState>(initialInspection);
|
||||
|
||||
let inflight: RequestId | null = null;
|
||||
|
||||
@@ -119,6 +121,13 @@ export function cancelInspection() {
|
||||
void commands.cancelRequest(inflight).catch(() => undefined);
|
||||
}
|
||||
|
||||
/** The window switched projects: stops the run and forgets its results. */
|
||||
export function resetInspection() {
|
||||
cancelInspection();
|
||||
inflight = null;
|
||||
useInspection.setState(initialInspection());
|
||||
}
|
||||
|
||||
export async function runInspection(choice: ScopeChoice): Promise<void> {
|
||||
const scope = await resolveScope(choice);
|
||||
if (typeof scope === "string") {
|
||||
|
||||
Reference in new issue
Заблокувати користувача