fix: apply address bar rule without page URL#125
Open
liby wants to merge 1 commit into
Open
Conversation
An empty Chrome omnibox exposes no web-area URL, so `AppKind.from` classified the browser as a normal app and the address bar default input source rule only fired after the first keystroke. Forcing the switch mid-composition left the Pinyin candidate window orphaned and the omnibox unresponsive to Enter and Delete (runjuu#99). - Make `BrowserInfo.url` optional and treat address bar focus alone as a browser context, so the rule fires on focus, before typing starts. - Keep the context stable while the address bar stays focused: URL changes then reflect omnibox edits or suggestions rather than navigation, and must not re-trigger input source switches. - Skip website ids for browser states without a URL and unwrap the now-optional URL in the browser rule menu. - Cover `makeBrowserInfo` and context comparison in `AppKindComparisonTests`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #99
Problem
With a Browser Rules address bar default input source configured, focusing an empty Chrome omnibox and typing while a Pinyin input source is active switches the input source only after the first keystroke. The switch lands mid-composition, which can leave an orphaned candidate window: the omnibox stops responding to Enter and Delete until the input source is toggled manually.
Root cause
An empty omnibox exposes no observable web-area URL, so
AppKind.fromclassified the browser as a normal app and the address bar rule could not fire on focus. It only fired after the first key triggered another accessibility event.Changes
BrowserInfo.urloptional and treat address bar focus alone as a browser context, so the address bar rule applies on focus, before typing starts (AppKind.makeBrowserInfo).isSameAppOrWebsite).StatusItemController's browser rule menu.Testing
Tests/AppKindComparisonTests.swift(9 cases) covering browser context creation with and without a URL, entering/leaving the address bar, suggestion-driven URL changes, and navigation (run via Cmd+U).