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

Select in visual mode when scrolling #1859

Merged
merged 2 commits into from
Jun 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 3 additions & 7 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ class CommandCtrlOpenBracket extends CommandEsc {
}

abstract class CommandEditorScroll extends BaseCommand {
modes = [ModeName.Normal];
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine, ModeName.VisualBlock];
runsOnceForEachCountPrefix = false;
keys: string[];
to: EditorScrollDirection;
Expand All @@ -537,10 +537,10 @@ abstract class CommandEditorScroll extends BaseCommand {
to: this.to,
by: this.by,
value: timesToRepeat,
revealCursor: true
revealCursor: true,
select: [ModeName.Visual, ModeName.VisualBlock, ModeName.VisualLine].indexOf(vimState.currentMode) >= 0
}
});

return vimState;
}
}
Expand All @@ -561,31 +561,27 @@ class CommandCtrlY extends CommandEditorScroll {

@RegisterAction
class CommandMoveFullPageUp extends CommandEditorScroll {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine, ModeName.VisualBlock];
keys = ["<C-b>"];
to: EditorScrollDirection = "up";
by: EditorScrollByUnit = "page";
}

@RegisterAction
class CommandMoveFullPageDown extends CommandEditorScroll {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine, ModeName.VisualBlock];
keys = ["<C-f>"];
to: EditorScrollDirection = "down";
by: EditorScrollByUnit = "page";
}

@RegisterAction
class CommandMoveHalfPageDown extends CommandEditorScroll {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine, ModeName.VisualBlock];
keys = ["<C-d>"];
to: EditorScrollDirection = "down";
by: EditorScrollByUnit = "halfPage";
}

@RegisterAction
class CommandMoveHalfPageUp extends CommandEditorScroll {
modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine, ModeName.VisualBlock];
keys = ["<C-u>"];
to: EditorScrollDirection = "up";
by: EditorScrollByUnit = "halfPage";
Expand Down
2 changes: 2 additions & 0 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { Globals } from '../../src/globals';
import { ReplaceState } from './../state/replaceState';
import { GlobalState } from './../state/globalState';
import { Nvim } from "promised-neovim-client";
import { allowVSCodeToPropagateCursorUpdatesAndReturnThem } from "../util";

export class ViewChange {
public command: string;
Expand Down Expand Up @@ -1782,6 +1783,7 @@ export class ModeHandler implements vscode.Disposable {
for (let i = 0; i < this.vimState.postponedCodeViewChanges.length; i++) {
let viewChange = this.vimState.postponedCodeViewChanges[i];
await vscode.commands.executeCommand(viewChange.command, viewChange.args);
vimState.allCursors = await allowVSCodeToPropagateCursorUpdatesAndReturnThem();
}

// If user wants to change status bar color based on mode
Expand Down