Skip to content

Commit

Permalink
Merge pull request #218 from aioutecism/fix/searching-behaviour
Browse files Browse the repository at this point in the history
Focus back to text when pressing enter at find widget
  • Loading branch information
aioutecism authored Jun 26, 2018
2 parents d9b952f + 1386f8e commit 623f886
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
{ "command": "amVim.ctrl+f", "key": "ctrl+f", "when": "editorTextFocus && amVim.configuration.shouldBindCtrlCommands && amVim.mode != 'INSERT'" },
{ "command": "amVim.ctrl+b", "key": "ctrl+b", "when": "editorTextFocus && amVim.configuration.shouldBindCtrlCommands && amVim.mode != 'INSERT'" },

{ "key": "enter", "command": "amVim.executeNativeFind", "when": "editorFocus && findInputFocussed && findWidgetVisible" },

{ "key": "j", "command": "list.focusDown", "when": "amVim.configuration.shouldUseVimStyleNavigationInListView && listFocus && !inputFocus" },
{ "key": "k", "command": "list.focusUp", "when": "amVim.configuration.shouldUseVimStyleNavigationInListView && listFocus && !inputFocus" },
{ "key": "o", "command": "list.toggleExpand", "when": "amVim.configuration.shouldUseVimStyleNavigationInListView && listFocus && !inputFocus" },
Expand Down
6 changes: 6 additions & 0 deletions src/Actions/Find.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import {window, commands, Selection} from 'vscode';
import {ActionSelection} from './Selection';

export class ActionFind {

static focusFindWidget(): Thenable<boolean | undefined> {
return commands.executeCommand('actions.find');
}

static executeNativeFind(): Thenable<boolean> {
return commands.executeCommand('search.action.focusActiveEditor')
.then(ActionSelection.shrinkToEnds);
}

// TODO: Implement independent find function to avoid incorrect cursor position after `next()`

static byIndicator(): Thenable<boolean | undefined> {
Expand Down
3 changes: 3 additions & 0 deletions src/Dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {ModeVisual} from './Modes/Visual';
import {ModeVisualLine} from './Modes/VisualLine';
import {ModeInsert} from './Modes/Insert';
import {ActionMode} from './Actions/Mode';
import {ActionFind} from './Actions/Find';
import {ActionMoveCursor} from './Actions/MoveCursor';
import {Configuration} from './Configuration';

Expand Down Expand Up @@ -43,6 +44,8 @@ export class Dispatcher {
context.subscriptions.push(commands.registerCommand(`amVim.${key}`, this.inputHandler(key)));
});

context.subscriptions.push(commands.registerCommand('amVim.executeNativeFind', ActionFind.executeNativeFind));

ActionMoveCursor.updatePreferredColumn();

this.switchMode(Configuration.defaultModeID);
Expand Down

0 comments on commit 623f886

Please sign in to comment.