mirror of
https://github.com/jasonwilliams/vscode-helix.git
synced 2024-10-06 13:17:15 +03:00
v0.6.2
This commit is contained in:
parent
a2417223bb
commit
ad779c6282
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vscode-helix-emulation",
|
||||
"version": "0.6.1",
|
||||
"version": "0.6.2",
|
||||
"displayName": "Helix For VS Code",
|
||||
"description": "Helix emulation for Visual Studio Code",
|
||||
"publisher": "jasew",
|
||||
@ -277,17 +277,17 @@
|
||||
{
|
||||
"key": "alt+OEM_8",
|
||||
"command": "extension.helixKeymap.switchToUppercase",
|
||||
"when": "(extension.helixKeymap.normalMode || extension.helixKeymap.visualMode)"
|
||||
"when": "editorTextFocus && (extension.helixKeymap.normalMode || extension.helixKeymap.visualMode)"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+a",
|
||||
"command": "extension.helixKeymap.increment",
|
||||
"when": "(extension.helixKeymap.normalMode || extension.helixKeymap.visualMode)"
|
||||
"when": "editorTextFocus && (extension.helixKeymap.normalMode || extension.helixKeymap.visualMode)"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+x",
|
||||
"command": "extension.helixKeymap.decrement",
|
||||
"when": "(extension.helixKeymap.normalMode || extension.helixKeymap.visualMode)"
|
||||
"when": "editorTextFocus && (extension.helixKeymap.normalMode || extension.helixKeymap.visualMode)"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
|
@ -3,6 +3,7 @@ import { Action } from '../action_types';
|
||||
import { HelixState } from '../helix_state_types';
|
||||
import {
|
||||
enterInsertMode,
|
||||
enterNormalMode,
|
||||
enterSearchMode,
|
||||
enterSelectMode,
|
||||
enterVisualLineMode,
|
||||
@ -19,7 +20,7 @@ import { flashYankHighlight } from '../yank_highlight';
|
||||
import { gotoActions } from './gotoMode';
|
||||
import KeyMap from './keymaps';
|
||||
import { matchActions } from './matchMode';
|
||||
import { yank } from './operators';
|
||||
import { isSingleLineRange, yank } from './operators';
|
||||
import { spaceActions } from './spaceMode';
|
||||
import { unimparedActions } from './unimpared';
|
||||
import { viewActions } from './viewMode';
|
||||
@ -83,10 +84,6 @@ export const actions: Action[] = [
|
||||
vscode.commands.executeCommand('actions.findWithSelection');
|
||||
}),
|
||||
|
||||
parseKeysExact(['d'], [Mode.Normal], (_) => {
|
||||
vscode.commands.executeCommand('deleteRight');
|
||||
}),
|
||||
|
||||
parseKeysExact(['>'], [Mode.Normal, Mode.Visual], (_) => {
|
||||
vscode.commands.executeCommand('editor.action.indentLines');
|
||||
}),
|
||||
@ -306,8 +303,14 @@ export const actions: Action[] = [
|
||||
parseKeysExact(['y'], [Mode.Normal, Mode.Visual], (vimState, editor) => {
|
||||
// Yank highlight
|
||||
const highlightRanges = editor.selections.map((selection) => selection.with());
|
||||
|
||||
// We need to detect if the ranges are lines because we need to handle them differently
|
||||
highlightRanges.every((range) => isSingleLineRange(range));
|
||||
yank(vimState, editor, highlightRanges, false);
|
||||
flashYankHighlight(editor, highlightRanges);
|
||||
if (vimState.mode === Mode.Visual) {
|
||||
enterNormalMode(vimState);
|
||||
}
|
||||
}),
|
||||
|
||||
parseKeysExact(['q', 'q'], [Mode.Normal, Mode.Visual], () => {
|
||||
|
@ -5,7 +5,7 @@ import { Mode } from '../modes_types';
|
||||
import { parseKeysExact, parseKeysRegex } from '../parse_keys';
|
||||
import { searchBackwardBracket, searchForwardBracket } from '../search_utils';
|
||||
import { removeTypeSubscription } from '../type_subscription';
|
||||
import { delete_ } from './operators';
|
||||
import { delete_, yank } from './operators';
|
||||
|
||||
export const matchActions: Action[] = [
|
||||
// Implemenent jump to bracket
|
||||
@ -18,8 +18,9 @@ export const matchActions: Action[] = [
|
||||
}),
|
||||
|
||||
// Delete match
|
||||
parseKeysExact(['d'], [Mode.Normal, Mode.Visual], (_, editor) => {
|
||||
parseKeysExact(['d'], [Mode.Normal, Mode.Visual], (helixState, editor) => {
|
||||
const ranges = editor.selections.map((selection) => selection.with());
|
||||
yank(helixState, editor, ranges, false);
|
||||
delete_(editor, ranges, false);
|
||||
}),
|
||||
|
||||
|
@ -73,6 +73,11 @@ function cursorsToRangesStart(editor: vscode.TextEditor, ranges: readonly (vscod
|
||||
}
|
||||
|
||||
export function delete_(editor: vscode.TextEditor, ranges: (vscode.Range | undefined)[], linewise: boolean) {
|
||||
if (ranges.length === 1 && ranges[0] && isEmptyRange(ranges[0])) {
|
||||
vscode.commands.executeCommand('deleteRight');
|
||||
return;
|
||||
}
|
||||
|
||||
editor
|
||||
.edit((editBuilder) => {
|
||||
ranges.forEach((range) => {
|
||||
@ -133,3 +138,15 @@ export function yank(
|
||||
linewise: linewise,
|
||||
};
|
||||
}
|
||||
|
||||
// detect if a range is covering just a single character
|
||||
function isEmptyRange(range: vscode.Range) {
|
||||
return range.start.line === range.end.line && range.start.character === range.end.character;
|
||||
}
|
||||
|
||||
// detect if the range spans a whole line and only one line
|
||||
// Theres a weird issue where the cursor jumps to the next line when doing expand line selection
|
||||
// https://github.com/microsoft/vscode/issues/118015#issuecomment-854964022
|
||||
export function isSingleLineRange(range: vscode.Range): boolean {
|
||||
return range.start.line === range.end.line && range.start.character === 0 && range.end.character === 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user