Wiring debounce change upate to minimap-view
This commit is contained in:
parent
a6b0bda263
commit
051e42bfa3
@ -34,8 +34,10 @@ export class CodeViewBase {
|
|||||||
public editor!: any;
|
public editor!: any;
|
||||||
public activeFile!: NewtonFile;
|
public activeFile!: NewtonFile;
|
||||||
|
|
||||||
public cutBuffer: string = "";
|
public cutBuffer: string = "";
|
||||||
public timerId: number = -1;
|
public timerId: number = -1;
|
||||||
|
public debounceId: number = -1;
|
||||||
|
public debounceWait: number = 2000;
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -179,7 +181,7 @@ export class CodeViewBase {
|
|||||||
|
|
||||||
editorComponent.editor.moveCursorToPosition(pos);
|
editorComponent.editor.moveCursorToPosition(pos);
|
||||||
editorComponent.editor.clearSelection();
|
editorComponent.editor.clearSelection();
|
||||||
editorComponent.editor.renderer.scrollCursorIntoView();
|
editorComponent.editor.renderer.scrollCursorIntoView(null, 0.5);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editor.on("mousewheel", (event) => {
|
this.editor.on("mousewheel", (event) => {
|
||||||
|
@ -140,11 +140,14 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
|
|
||||||
this.editor.on("change", () => {
|
this.editor.on("change", () => {
|
||||||
if (!this.activeFile) return;
|
if (!this.activeFile) return;
|
||||||
|
if (this.debounceId) { clearTimeout(this.debounceId); }
|
||||||
|
|
||||||
let message = new ServiceMessage();
|
let message = new ServiceMessage();
|
||||||
message.action = "file-changed";
|
message.action = "file-changed";
|
||||||
message.filePath = this.activeFile.path;
|
message.filePath = this.activeFile.path;
|
||||||
this.tabsService.sendMessage(message);
|
this.tabsService.sendMessage(message);
|
||||||
|
|
||||||
|
this.setDebounceTimeout();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editor.on("changeSession", (session) => {
|
this.editor.on("changeSession", (session) => {
|
||||||
@ -244,4 +247,14 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setDebounceTimeout(timeout: number = null) {
|
||||||
|
this.debounceId = setTimeout(() => {
|
||||||
|
this.editorsService.miniMapView.editor.session.setValue(
|
||||||
|
this.editor.session.getValue()
|
||||||
|
);
|
||||||
|
|
||||||
|
this.debounceId = -1;
|
||||||
|
}, (timeout) ? timeout : this.debounceWait);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user