Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/squirrel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ app_options:
com.apple.Terminal:
ascii_mode: true
no_inline: true
org.alacritty:
# Work around https://github.com/rime/squirrel/issues/741
force_marked_text_for_direct_commit: true
com.googlecode.iterm2:
ascii_mode: true
no_inline: true
Expand Down
4 changes: 2 additions & 2 deletions package/add_data_files
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ add_lib() {
}

data_files=(
$(ls data/plum/* | xargs basename)
$(for file in data/plum/*; do basename "$file"; done)

Copy link
Copy Markdown
Member

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.

)

lib_files=(
$(ls lib/rime-plugins/* | xargs basename)
$(for file in lib/rime-plugins/*; do basename "$file"; done)
)

for file in "${data_files[@]}"
Expand Down
17 changes: 17 additions & 0 deletions sources/SquirrelInputController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
}

// Preserve reserved comment marks when librime requests a UI-only refresh.
func rimeUpdate(clearReservedComments: Bool = true) {

Check warning on line 448 in sources/SquirrelInputController.swift

View workflow job for this annotation

GitHub Actions / build

Function should have complexity 10 or less; currently complexity is 13 (cyclomatic_complexity)
if clearReservedComments {
specialCommentIndices = [:]
}
Expand Down Expand Up @@ -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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up after testing: I tried enabling force_marked_text_for_direct_commit globally. With the earlier implementation, Microsoft Word showed font fallback after direct commits. The synthetic marked-text cleanup added in #1171 has fixed that issue in my current testing. I am still testing this more broadly, so I do not think it should become the global default yet; #1171 keeps it app-scoped and enables it only for the known affected clients, Alacritty and VS Code.

markedText,
selectionRange: NSRange(location: markedText.length, length: 0),
replacementRange: .empty
)
}

client.insertText(string, replacementRange: .empty)
preedit = ""
hidePalettes()
Expand Down
Loading