Supporting visual mode in some operators

This commit is contained in:
jasonwilliams 2024-01-07 16:33:33 +00:00
parent c5e9b183be
commit 5c4ca51485
3 changed files with 16 additions and 5 deletions

View File

@ -174,7 +174,17 @@
{
"key": "alt+;",
"command": "extension.helixKeymap.flipSelection",
"when": "extension.helixKeymap.normalMode"
"when": "!extension.helixKeymap.insertMode && editorTextFocus"
},
{
"key": "alt+k",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus && !extension.helixKeymap.insertMode"
},
{
"key": "alt+j",
"command": "editor.action.moveLinesDownAction",
"when": "editorTextFocus && !extension.helixKeymap.insertMode"
}
],
"configuration": {

View File

@ -53,13 +53,13 @@ export const actions: Action[] = [
}),
// Selection Stuff
parseKeysExact(['s'], [Mode.Normal], (helixState, editor) => {
parseKeysExact(['s'], [Mode.Normal, Mode.Visual], (helixState, editor) => {
enterSelectMode(helixState);
// if we enter select mode we should save the current selection
helixState.currentSelection = editor.selection;
}),
parseKeysExact([','], [Mode.Normal], (_, editor) => {
parseKeysExact([','], [Mode.Normal, Mode.Visual], (_, editor) => {
// Keep primary selection only
editor.selections = editor.selections.slice(0, 1);
}),

View File

@ -2,7 +2,7 @@ import * as vscode from 'vscode';
import { Action } from '../action_types';
import { HelixState } from '../helix_state_types';
import { enterNormalMode, setModeCursorStyle } from '../modes';
import { enterNormalMode, enterVisualMode, setModeCursorStyle } from '../modes';
import { Mode } from '../modes_types';
import { parseKeysOperator } from '../parse_keys';
import { operatorRanges } from './operator_ranges';
@ -93,11 +93,12 @@ export const operators: Action[] = [
if (linewise) {
// enterVisualLineMode(vimState);
} else {
// enterVisualMode(vimState);
enterVisualMode(vimState);
}
setModeCursorStyle(vimState.mode, editor);
}),
parseKeysOperator(['q'], operatorRanges, (vimState, editor, ranges, _linewise) => {
if (ranges.every((x) => x === undefined) || vimState.mode === Mode.Visual || vimState.mode === Mode.VisualLine) {
return;