- Clear selections on insert fixes #14

- Fix #15
This commit is contained in:
jasonwilliams 2024-01-29 22:07:10 +00:00
parent 148d9c661d
commit 1bdab8436d
2 changed files with 16 additions and 2 deletions

View File

@ -19,18 +19,26 @@ import { whitespaceWordRanges, wordRanges } from '../word_utils';
import KeyMap from './keymaps';
export const motions: Action[] = [
parseKeysExact([KeyMap.Motions.MoveRight], [Mode.Normal, Mode.Visual], (vimState, editor) => {
parseKeysExact([KeyMap.Motions.MoveRight], [Mode.Visual], (vimState, editor) => {
execMotion(vimState, editor, ({ document, position }) => {
return positionUtils.rightNormal(document, position, vimState.resolveCount());
});
}),
parseKeysExact([KeyMap.Motions.MoveLeft], [Mode.Normal, Mode.Visual], (vimState, editor) => {
parseKeysExact([KeyMap.Motions.MoveLeft], [Mode.Visual], (vimState, editor) => {
execMotion(vimState, editor, ({ position }) => {
return positionUtils.left(position, vimState.resolveCount());
});
}),
parseKeysExact([KeyMap.Motions.MoveRight], [Mode.Normal], () => {
vscode.commands.executeCommand('cursorRight');
}),
parseKeysExact([KeyMap.Motions.MoveLeft], [Mode.Normal], () => {
vscode.commands.executeCommand('cursorLeft');
}),
parseKeysExact([KeyMap.Motions.MoveUp], [Mode.Normal], (_vimState, _editor) => {
vscode.commands.executeCommand('cursorMove', {
to: 'up',

View File

@ -5,6 +5,12 @@ import { Mode } from './modes_types';
import { removeTypeSubscription } from './type_subscription';
export function enterInsertMode(helixState: HelixState): void {
// To fix https://github.com/jasonwilliams/vscode-helix/issues/14 we should clear selections on entering insert mode
// Helix doesn't clear selections on insert but doesn't overwrite the selection either, so our best option is to just clear them
const editor = helixState.editorState.activeEditor!;
const activeSelection = editor.selection.active;
editor.selections = [new vscode.Selection(activeSelection, activeSelection)];
helixState.mode = Mode.Insert;
setModeContext('extension.helixKeymap.insertMode');
helixState.commandLine.setText('', helixState);