-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as node from '../node'; | ||
import { Logger } from '../../util/logger'; | ||
import { VimState } from '../../state/vimState'; | ||
import { CommandUndo } from '../../actions/commands/actions'; | ||
import { Position } from '../../common/motion/position'; | ||
|
||
// | ||
// Implements :u[ndo] | ||
// http://vimdoc.sourceforge.net/htmldoc/undo.html | ||
// | ||
export class UndoCommand extends node.CommandBase { | ||
protected _arguments: {}; | ||
private readonly _logger = Logger.get('Undo'); | ||
|
||
constructor(args: {}) { | ||
super(); | ||
this._arguments = args; | ||
} | ||
|
||
get arguments(): {} { | ||
return this._arguments; | ||
} | ||
|
||
async execute(vimState: VimState): Promise<void> { | ||
await new CommandUndo().exec(new Position(0, 0), vimState); | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getAndUpdateModeHandler } from '../../extension'; | ||
import { commandLine } from '../../src/cmd_line/commandLine'; | ||
import { ModeHandler } from '../../src/mode/modeHandler'; | ||
import { assertEqualLines, cleanUpWorkspace, setupWorkspace } from '../testUtils'; | ||
import { VimState } from '../../src/state/vimState'; | ||
|
||
suite('Undo command', () => { | ||
let modeHandler: ModeHandler; | ||
|
||
setup(async () => { | ||
await setupWorkspace(); | ||
modeHandler = await getAndUpdateModeHandler(); | ||
}); | ||
|
||
teardown(cleanUpWorkspace); | ||
|
||
test('undoes last action after insert mode', async () => { | ||
await modeHandler.handleMultipleKeyEvents(['i', 'a', '<Esc>']); | ||
await modeHandler.handleMultipleKeyEvents(['i', 'b', '<Esc>']); | ||
await commandLine.Run('undo', modeHandler.vimState); | ||
assertEqualLines(['a']); | ||
}); | ||
}); |