Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsers and state in content #962

Merged
merged 11 commits into from Sep 4, 2018

Un-regress hinting and finding

Turned out this was simple - I'd forgotten to switch the controller to
use the content versions of hinting and finding, so the controller was
using the background versions which were messaging-based proxies for
the content versions that weren't running any more. Calling the
content versions directly fixed hinting immediately.
  • Loading branch information...
saulrh committed Sep 1, 2018
commit fc08fa447164e127c2c1d4fd1fa7c1bc23c58d7e
@@ -10,7 +10,6 @@ import * as commandline_background from "./commandline_background"
import * as convert from "./convert"
import * as config from "./config"
import * as dom from "./dom"
import * as hinting_background from "./hinting_background"
import * as download_background from "./download_background"
import * as itertools from "./itertools"
import * as keyseq from "./keyseq"
@@ -27,7 +26,6 @@ import { AutoContain } from "./lib/autocontainers"
convert,
config,
dom,
hinting_background,
download_background,
itertools,
native,
@@ -6,8 +6,8 @@ import Logger from "./logging"
import * as messaging from "./messaging"

import { parser as exmode_parser } from "./parsers/exmode"
import { parser as hintmode_parser } from "./hinting_background"
import { parser as findmode_parser } from "./finding_background"
import * as hinting from "./hinting"
import * as finding from "./finding"
import * as gobblemode from "./parsers/gobblemode"
import * as generic from "./parsers/genericmode"

@@ -21,8 +21,8 @@ function* ParserController() {
insert: keys => generic.parser("imaps", keys),
input: keys => generic.parser("inputmaps", keys),
ignore: keys => generic.parser("ignoremaps", keys),
hint: hintmode_parser,
find: findmode_parser,
hint: hinting.parser,
find: finding.parser,
gobble: gobblemode.parser,
}

@@ -58,7 +58,6 @@ function* ParserController() {
} else if (currentMode === "input" && !textEditable) {
contentState.mode = "normal"
}
logger.debug(keyevent_safe, contentState.mode)

// Accumulate key events. The parser will cut this
// down whenever it's not a valid prefix of a known
@@ -69,7 +68,7 @@ function* ParserController() {

let response = undefined
response = (parsers[contentState.mode] as any)(keyEvents)
logger.debug(keyEvents, response)
logger.debug(currentMode, contentState.mode, keyEvents, response)

if (response.isMatch) {
keyevent_raw.preventDefault()
@@ -149,14 +149,9 @@ function pushKey(ke) {
}
}

import { addListener, attributeCaller } from "./messaging"
addListener(
"finding_content",
attributeCaller({
pushKey,
mode,
reset,
findPage,
navigate,
}),
)
export function parser(keys: KeyboardEvent[]) {
for (const { key } of keys) {
pushKey(key)
}
return { keys: [], ex_str: "" }
}

This file was deleted.

@@ -450,8 +450,6 @@ function filterHintsVimperator(fstr, reflow = false) {
}

/** Remove all hints, reset STATE.
* If abort is true, we're resetting because the user pressed escape.
* If it is false, we're resetting because the user selected a hint.
**/
function reset() {
if (modeState) {
@@ -545,12 +543,15 @@ function selectFocusedHint(delay = false) {
else focused.select()
}

import { addListener, attributeCaller } from "./messaging"
addListener(
"hinting_content",
attributeCaller({
pushKey,
selectFocusedHint,
reset,
}),
)
export function parser(keys: KeyboardEvent[]) {
for (const { key } of keys) {
if (key === "Escape") {
reset()
} else if (["Enter", " "].includes(key)) {
selectFocusedHint()
} else {
pushKey(keys[0])
}
}
return { keys: [], ex_str: "" }
}

This file was deleted.

@@ -6,8 +6,6 @@ export type TabMessageType =
| "excmd_content"
| "commandline_content"
| "commandline_frame"
| "hinting_content"
| "finding_content"
export type NonTabMessageType =
| "commandline_background"
| "controller_background"
@@ -82,9 +80,7 @@ export async function messageTab(tabId, type: TabMessageType, command, args?) {
command,
args,
}
return browserBg.tabs.sendMessage(tabId, message).catch((e) => {
logger.error(e, tabId, message)
})
return browserBg.tabs.sendMessage(tabId, message)
}

export async function messageAllTabs(
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.