Merge pull request #1655 from tridactyl/fix-commandline-races

Don't send ex.* excmds around the houses
This commit is contained in:
Oliver Blanthorn 2019-06-04 11:57:35 +01:00 committed by GitHub
commit 8b112f2d0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -171,17 +171,24 @@ commandline_state.clInput.addEventListener(
commandline_state.keyEvents = []
history_called = false
// Send excmds directly to our own tab, which fixes the
// old bug where a command would be issued in one tab but
// land in another because the active tab had
// changed. Background-mode excmds will be received by the
// own tab's content script and then bounced through a
// shim to the background, but the latency increase should
// be acceptable becuase the background-mode excmds tend
// to be a touch less latency-sensitive.
Messaging.messageOwnTab("controller_content", "acceptExCmd", [
response.exstr,
]).then(_ => (prev_cmd_called_history = history_called))
// If excmds start with 'ex.' they're coming back to us anyway, so skip that.
if (response.exstr.startsWith("ex.")) {
const funcname = response.exstr.slice(3)
commandline_state.fns[funcname]()
prev_cmd_called_history = history_called
} else {
// Send excmds directly to our own tab, which fixes the
// old bug where a command would be issued in one tab but
// land in another because the active tab had
// changed. Background-mode excmds will be received by the
// own tab's content script and then bounced through a
// shim to the background, but the latency increase should
// be acceptable becuase the background-mode excmds tend
// to be a touch less latency-sensitive.
Messaging.messageOwnTab("controller_content", "acceptExCmd", [
response.exstr,
]).then(_ => (prev_cmd_called_history = history_called))
}
} else {
commandline_state.keyEvents = response.keys
}