Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions Vimari Extension/js/injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,21 @@ function boundKeys() {
// Stops propagation of keyboard events in normal mode. Adding this
// callback to the document using the useCapture flag allows us to
// prevent custom key behaviour implemented by the underlying website.
function stopSitePropagation() {
return function (e) {
if (insertMode) {
// Never stop propagation in insert mode.
return
}
function stopSitePropagation(e) {
if (insertMode) {
// Never stop propagation in insert mode.
return
}

if (settings.transparentBindings === true) {
if (boundKeys().has(e.key) && !isActiveElementEditable()) {
// If we are in normal mode with transparentBindings enabled we
// should only stop propagation in an editable element or if the
// key is bound to a Vimari action.
e.stopPropagation()
}
} else if (!isActiveElementEditable()) {
if (settings.transparentBindings === true) {
if (boundKeys().has(e.key) && !isActiveElementEditable()) {
// If we are in normal mode with transparentBindings enabled we
// should only stop propagation in an editable element or if the
// key is bound to a Vimari action.
e.stopPropagation()
}
} else if (!isActiveElementEditable()) {
e.stopPropagation()
}
}

Expand Down Expand Up @@ -355,8 +353,11 @@ function activateExtension(settings) {
return;
}

// Clear any existing events
unbindKeyCodes();

// Stop keydown propagation
document.addEventListener("keydown", stopSitePropagation(), true);
document.addEventListener("keydown", stopSitePropagation, true);
bindKeyCodesToActions(settings);
}

Expand Down