diff --git a/src/app/editor/code-view/view.base.ts b/src/app/editor/code-view/view.base.ts index ae6785d..1b68e2f 100644 --- a/src/app/editor/code-view/view.base.ts +++ b/src/app/editor/code-view/view.base.ts @@ -34,8 +34,10 @@ export class CodeViewBase { public editor!: any; public activeFile!: NewtonFile; - public cutBuffer: string = ""; - public timerId: number = -1; + public cutBuffer: string = ""; + public timerId: number = -1; + public debounceId: number = -1; + public debounceWait: number = 2000; constructor() { @@ -179,7 +181,7 @@ export class CodeViewBase { editorComponent.editor.moveCursorToPosition(pos); editorComponent.editor.clearSelection(); - editorComponent.editor.renderer.scrollCursorIntoView(); + editorComponent.editor.renderer.scrollCursorIntoView(null, 0.5); }); this.editor.on("mousewheel", (event) => { @@ -249,4 +251,4 @@ export class CodeViewBase { private quit() { window.main.quit(); } -} +} \ No newline at end of file diff --git a/src/app/editor/code-view/view.component.ts b/src/app/editor/code-view/view.component.ts index b1739f7..e4c68c6 100644 --- a/src/app/editor/code-view/view.component.ts +++ b/src/app/editor/code-view/view.component.ts @@ -140,11 +140,14 @@ export class CodeViewComponent extends CodeViewBase { this.editor.on("change", () => { if (!this.activeFile) return; + if (this.debounceId) { clearTimeout(this.debounceId); } let message = new ServiceMessage(); message.action = "file-changed"; message.filePath = this.activeFile.path; this.tabsService.sendMessage(message); + + this.setDebounceTimeout(); }); this.editor.on("changeSession", (session) => { @@ -244,4 +247,14 @@ export class CodeViewComponent extends CodeViewBase { }, 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); + } + } \ No newline at end of file