-
Notifications
You must be signed in to change notification settings - Fork 540
fix: support direct commits in marked text clients #1165
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -445,7 +445,7 @@ | |
| } | ||
|
|
||
| // Preserve reserved comment marks when librime requests a UI-only refresh. | ||
| func rimeUpdate(clearReservedComments: Bool = true) { | ||
| if clearReservedComments { | ||
| specialCommentIndices = [:] | ||
| } | ||
|
|
@@ -561,6 +561,23 @@ | |
|
|
||
| func commit(string: String) { | ||
| guard let client = client else { return } | ||
|
|
||
| let forceMarkedText = | ||
| session != 0 && | ||
| rimeAPI.get_option(session, "force_marked_text_for_direct_commit") | ||
|
|
||
| // Direct commits such as full-width punctuation do not necessarily have an | ||
| // active marked-text phase. Some NSTextInputClient implementations require | ||
| // one before accepting insertText. | ||
| if forceMarkedText && preedit.isEmpty && !string.isEmpty { | ||
| let markedText = NSMutableAttributedString(string: string) | ||
| client.setMarkedText( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Is it possible that we always do it when committing text without marked text? We can experiment with the current solution to see if there are side effects in normal cases, and make it the default behaviour at some point.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow-up after testing: I tried enabling |
||
| markedText, | ||
| selectionRange: NSRange(location: markedText.length, length: 0), | ||
| replacementRange: .empty | ||
| ) | ||
| } | ||
|
|
||
| client.insertText(string, replacementRange: .empty) | ||
| preedit = "" | ||
| hidePalettes() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is nice to have, but better be in a separate git commit.