Fix insert after or before

This commit is contained in:
jasonwilliams 2024-02-01 22:04:30 +00:00
parent fbf35b4e1d
commit 9b7bd51351
2 changed files with 6 additions and 9 deletions

View File

@ -131,12 +131,7 @@ export const actions: Action[] = [
}),
parseKeysExact(['a'], [Mode.Normal], (vimState, editor) => {
editor.selections = editor.selections.map((selection) => {
const newPosition = positionUtils.right(editor.document, selection.active);
return new vscode.Selection(newPosition, newPosition);
});
enterInsertMode(vimState);
enterInsertMode(vimState, false);
setModeCursorStyle(vimState.mode, editor);
removeTypeSubscription(vimState);
}),

View File

@ -4,12 +4,14 @@ import { HelixState } from './helix_state_types';
import { Mode } from './modes_types';
import { removeTypeSubscription } from './type_subscription';
export function enterInsertMode(helixState: HelixState): void {
export function enterInsertMode(helixState: HelixState, before = true): 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)];
editor.selections = editor.selections.map((selection) => {
const position = before ? selection.anchor : selection.active;
return new vscode.Selection(position, position);
});
helixState.mode = Mode.Insert;
setModeContext('extension.helixKeymap.insertMode');