diff --git a/spec/keymap-manager-spec.js b/spec/keymap-manager-spec.js index 6f8c82a..9b3ff62 100644 --- a/spec/keymap-manager-spec.js +++ b/spec/keymap-manager-spec.js @@ -2184,7 +2184,7 @@ describe('KeymapManager', function () { 'ctrl-a': 'x' ` ) - keymapManager.loadKeymap(keymapFilePath, { watch: true }) + keymapManager.loadKeymap(keymapFilePath, { watch: true, watchImmediately: true }) subscription = keymapManager.watchSubscriptions[keymapFilePath] return assert.equal( keymapManager.findKeyBindings({ command: 'x' }).length, @@ -2325,7 +2325,7 @@ describe('KeymapManager', function () { assert(!reloaded) // Can start watching again after cancelling - keymapManager.loadKeymap(keymapFilePath, { watch: true }) + keymapManager.loadKeymap(keymapFilePath, { watch: true, watchImmediately: true }) fs.writeFileSync( keymapFilePath, `\ diff --git a/src/keymap-manager.js b/src/keymap-manager.js index 569cf8c..54b24cf 100644 --- a/src/keymap-manager.js +++ b/src/keymap-manager.js @@ -448,7 +448,8 @@ module.exports = KeymapManager = (function () { options != null ? options.priority : undefined ) if (options != null ? options.watch : undefined) { - this.watchKeymap(bindingsPath, options) + const watch = () => this.watchKeymap(bindingsPath, options) + options.watchImmediately ? watch() : setTimeout(watch, 300) } }