Skip to content

Commit 9a1cb2d

Browse files
committed
fix: inactive view reloads document for active view
1 parent 89b4121 commit 9a1cb2d

3 files changed

Lines changed: 6 additions & 28 deletions

File tree

src/lang/lang.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export const lang = {
180180
hk_extend_select_to_end_of_group: 'Extend selection to end of group',
181181
hk_extend_select_to_start_of_column: 'Extend selection to start of column',
182182
hk_extend_select_to_end_of_column: 'Extend selection to end of column',
183-
hkg_selection: 'Selection',
183+
hkg_selection: 'Select',
184184
hk_select_all: 'Select all sections',
185185

186186
// navigate spatially
@@ -195,7 +195,7 @@ export const lang = {
195195
hk_go_to_beginning_of_column: 'Go to start of column',
196196
hk_go_to_end_of_column: 'Go to end of column',
197197
hk_select_parent: 'Select parent section',
198-
hkg_navigation: 'Navigation',
198+
hkg_navigation: 'Navigate',
199199
hk_select_previous_sibling: 'Select previous sibling',
200200
hk_select_next_sibling: 'Select next sibling',
201201

src/stores/view/subscriptions/on-document-state-update.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ export const onDocumentStateUpdate = (
8484
if (!container || !view.isViewOfFile) return;
8585

8686
if (e.content || structuralChange) {
87-
const debouncedSave = type === 'DOCUMENT/MOVE_NODE';
88-
view.saveDocument(debouncedSave);
87+
view.saveDocument();
8988
}
9089

9190
if (e.content || structuralChange) {

src/view/view.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export class LineageView extends TextFileView {
7070
id: string;
7171
zoomFactor: number;
7272
minimapDom: MinimapDomElements | null = null;
73-
private hasDebouncedSave = false;
7473
private readonly onDestroyCallbacks: Set<Unsubscriber> = new Set();
7574
private activeFilePath: null | string;
7675
constructor(
@@ -121,16 +120,11 @@ export class LineageView extends TextFileView {
121120
this.loadInitialData();
122121
} else {
123122
this.data = data;
124-
this.debouncedLoadDocumentToStore();
123+
if (this.isViewOfFile) this.debouncedLoadDocumentToStore();
125124
}
126125
}
127126

128127
async onUnloadFile() {
129-
if (this.hasDebouncedSave && this.data.length) {
130-
this.save();
131-
this.hasDebouncedSave = false;
132-
}
133-
134128
if (this.component) {
135129
this.component.$destroy();
136130
}
@@ -191,7 +185,7 @@ export class LineageView extends TextFileView {
191185
onPluginError(error, location, action);
192186
};
193187

194-
saveDocument = async (debounced = false) => {
188+
saveDocument = async () => {
195189
invariant(this.file);
196190
const state = clone(this.documentStore.getValue());
197191
const data: string =
@@ -202,25 +196,10 @@ export class LineageView extends TextFileView {
202196
throw new Error(lang.error_save_empty_data);
203197
}
204198
this.data = data;
205-
if (debounced) {
206-
this.debouncedSave();
207-
} else {
208-
this.requestSave();
209-
}
210-
this.hasDebouncedSave = debounced;
199+
this.requestSave();
211200
}
212201
};
213202

214-
private debouncedSave = debounce(
215-
() => {
216-
if (!this.hasDebouncedSave) return;
217-
this.save();
218-
this.hasDebouncedSave = false;
219-
},
220-
8000,
221-
true,
222-
);
223-
224203
private loadInitialData = async () => {
225204
invariant(this.file);
226205

0 commit comments

Comments
 (0)