Skip to content

Commit

Permalink
Start in insert mode if user is in a text input
Browse files Browse the repository at this point in the history
Fixes issue #37
  • Loading branch information
abrookins committed Aug 31, 2017
1 parent 190aa55 commit b21652a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sVim.safariextension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
<key>Author</key>
<string>Phillip Lanclos</string>
<key>Builder Version</key>
<string>12603.3.8</string>
<string>12604.1.38.1.6</string>
<key>CFBundleDisplayName</key>
<string>sVim</string>
<key>CFBundleIdentifier</key>
<string>com.flipxfx.svim</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0.5</string>
<string>1.0.6</string>
<key>CFBundleVersion</key>
<string>105</string>
<string>106</string>
<key>Chrome</key>
<dict>
<key>Database Quota</key>
Expand Down
11 changes: 9 additions & 2 deletions sVim.safariextension/sVimTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ sVimTab.bind = function() {

// Bind shortcuts to commands
for (var shortcut in sVimTab.settings.shortcuts) {
var command = sVimTab.settings.shortcuts[shortcut];
var command = sVimTab.settings.shortcuts[shortcut],
element = document.activeElement;

// Replace <Leader>
shortcut = shortcut.replace(/<[lL]eader>/g, sVimTab.settings.mapleader);
// Bind going into normal mode even in textboxes
Expand All @@ -348,7 +350,12 @@ sVimTab.bind = function() {
}

// Default to normal mode
sVimTab.commands["normalMode"]();
if (element && sVimHelper.isElementInput(element)) {
sVimTab.commands["insertMode"]();
}
else {
sVimTab.commands["normalMode"]();
}
};

// Prevent propagation for all keydown events if in normal mode, non-escape key is pressed or active element is input
Expand Down

0 comments on commit b21652a

Please sign in to comment.