Skip to content

Commit

Permalink
editor history: do not clear history when replacing entry
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 15, 2017
1 parent 12026f7 commit 0144724
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/vs/workbench/services/history/browser/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export abstract class BaseHistoryService {

// Debounce the event with a timeout of 0ms so that multiple calls to
// editor.setSelection() are folded into one. We do not want to record
// subsequent history navigations for such API calls.
// subsequent history navigations for such API calls.
this.activeEditorListeners.push(debounceEvent(control.onDidChangeCursorPosition, (last, event) => event, 0)((event => {
this.handleEditorSelectionChangeEvent(activeEditor, event);
})));
Expand Down Expand Up @@ -560,18 +560,19 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
const stackInput = this.preferResourceInput(input);
const entry = { input: stackInput, selection, timestamp: Date.now() };

// If we are not at the end of history, we remove anything after
if (this.stack.length > this.index + 1) {
this.stack = this.stack.slice(0, this.index + 1);
}

// Replace at current position
if (replace) {
this.stack[this.index] = entry;
}

// Add to stack at current position
else {

// If we are not at the end of history, we remove anything after
if (this.stack.length > this.index + 1) {
this.stack = this.stack.slice(0, this.index + 1);
}

this.setIndex(this.index + 1);
this.stack.splice(this.index, 0, entry);

Expand Down

0 comments on commit 0144724

Please sign in to comment.