mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
Fix commandline history capping
This commit is contained in:
parent
46a21c5a36
commit
f2effcefab
@ -32,7 +32,7 @@ export class CommandLineHistory {
|
||||
|
||||
// resize array if necessary
|
||||
if (this._history.length > configuration.history) {
|
||||
this._history = this._history.slice(0, configuration.history);
|
||||
this._history = this._history.slice(this._history.length - configuration.history);
|
||||
}
|
||||
|
||||
this.save();
|
||||
@ -41,7 +41,7 @@ export class CommandLineHistory {
|
||||
public get(): string[] {
|
||||
// resize array if necessary
|
||||
if (this._history.length > configuration.history) {
|
||||
this._history = this._history.slice(0, configuration.history);
|
||||
this._history = this._history.slice(this._history.length - configuration.history);
|
||||
}
|
||||
|
||||
return this._history;
|
||||
|
@ -66,12 +66,8 @@ suite('command-line history', () => {
|
||||
let added_cmd: string = String(configuration.history);
|
||||
run_cmds.push(added_cmd);
|
||||
history.add(added_cmd);
|
||||
assertArrayEquals(
|
||||
run_cmds
|
||||
.slice()
|
||||
.splice(1, configuration.history),
|
||||
history.get()
|
||||
);
|
||||
|
||||
assertArrayEquals(run_cmds.slice(1), history.get());
|
||||
});
|
||||
|
||||
test('add command that exists in history', async () => {
|
||||
@ -107,11 +103,6 @@ suite('command-line history', () => {
|
||||
history.add(cmd);
|
||||
}
|
||||
|
||||
assertArrayEquals(
|
||||
run_cmds
|
||||
.slice()
|
||||
.splice(run_cmds.length - 10),
|
||||
history.get()
|
||||
);
|
||||
assertArrayEquals(run_cmds.slice(run_cmds.length - configuration.history), history.get());
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user