mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-11 17:18:13 +01:00
Leak: history service (back/forward) navigation is unbounded (fixes #4362)
This commit is contained in:
@@ -232,7 +232,11 @@ interface IStackEntry {
|
||||
}
|
||||
|
||||
export class HistoryService extends BaseHistoryService implements IHistoryService {
|
||||
|
||||
public serviceId = IHistoryService;
|
||||
|
||||
private static MAX_HISTORY_ITEMS = 200;
|
||||
|
||||
private _stack: IStackEntry[];
|
||||
private index: number;
|
||||
private blockEditorEvent: boolean;
|
||||
@@ -369,6 +373,14 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
|
||||
else {
|
||||
this.index++;
|
||||
this.stack.splice(this.index, 0, entry);
|
||||
|
||||
// Check for limit
|
||||
if (this.stack.length > HistoryService.MAX_HISTORY_ITEMS) {
|
||||
this.stack.shift(); // remove first
|
||||
if (this.index > 0) {
|
||||
this.index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Take out on dispose
|
||||
|
||||
Reference in New Issue
Block a user