mirror of
https://github.com/jasonwilliams/vscode-helix.git
synced 2024-08-17 04:10:46 +03:00
Fix insert after or before
This commit is contained in:
parent
fbf35b4e1d
commit
9b7bd51351
@ -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);
|
||||
}),
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user