Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #1170 #1174

Merged
merged 3 commits into from
Dec 19, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2375,15 +2375,41 @@ class IndentOperatorInVisualModesIsAWeirdSpecialCase extends BaseOperator {

@RegisterAction
class OutdentOperator extends BaseOperator {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine];
modes = [ModeName.Normal];
keys = ["<"];

public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
vscode.window.activeTextEditor.selection = new vscode.Selection(start, end);

await vscode.commands.executeCommand("editor.action.outdentLines");
vimState.currentMode = ModeName.Normal;
vimState.cursorPosition = vimState.cursorStartPosition;
vimState.cursorPosition = start.getFirstLineNonBlankChar();

return vimState;
}
}

/**
* `3<` to outdent a line 3 times in visual mode is actually a bit of a special case.
*
* < is an operator, and generally speaking, you don't run operators multiple times, you run motions multiple times.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i dont think you need to copy my sassy comment 😁

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but I can remove it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha just leave a comment that points to the other comment.

* e.g. `d3w` runs `w` 3 times, then runs d once.
*
* Same with literally every other operator motion combination... until `3<`in visual mode
* walked into my life.
*/
@RegisterAction
class OutdentOperatorInVisualModesIsAWeirdSpecialCase extends BaseOperator {
modes = [ModeName.Visual, ModeName.VisualLine];
keys = ["<"];

public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
for (let i = 0; i < (vimState.recordedState.count || 1); i++) {
await vscode.commands.executeCommand("editor.action.outdentLines");
}

vimState.currentMode = ModeName.Normal;
vimState.cursorPosition = start.getFirstLineNonBlankChar();

return vimState;
}
Expand Down