diff --git a/src/vs/workbench/services/history/electron-browser/history.ts b/src/vs/workbench/services/history/electron-browser/history.ts index 0c81117700ba94f44ae9030588b45e3b200a321f..307fbf408d9d9f3d5ca744aa1957708b879f49d8 100644 --- a/src/vs/workbench/services/history/electron-browser/history.ts +++ b/src/vs/workbench/services/history/electron-browser/history.ts @@ -207,7 +207,9 @@ export class HistoryService extends Disposable implements IHistoryService { }))); // Track the last edit location by tracking model content change events - this.activeEditorListeners.push(activeTextEditorWidget.onDidChangeModelContent(() => { + // Use a debouncer to make sure to capture the correct cursor position + // after the model content has changed. + this.activeEditorListeners.push(debounceEvent(activeTextEditorWidget.onDidChangeModelContent, (last, event) => event, 0)((event => { const position = activeTextEditorWidget.getPosition(); this.lastEditLocation = { @@ -217,7 +219,7 @@ export class HistoryService extends Disposable implements IHistoryService { startColumn: position.column } }; - })); + }))); } }