Skip to content

Use correct walk snapshots for UOM observation - #895

Merged
zonble merged 1 commit into
openvanilla:masterfrom
lukhnos:walk-snapshot
Aug 8, 2026
Merged

Use correct walk snapshots for UOM observation#895
zonble merged 1 commit into
openvanilla:masterfrom
lukhnos:walk-snapshot

Conversation

@lukhnos

@lukhnos lukhnos commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #885

This syncs with openvanilla/fcitx5-mcbopomofo#276

UOM needs both the previous walk result and the current walk result after node override (that is, after user manually chooses a candidate) to make an observation, but since the nodes in a WalkResult are shared pointers to the Node instances in the grid, WalkResult does not capture an immutable snapshot. A new member function is introduced to enable getting a snapshot that has a real copy of the nodes, so as to capture the state of the grid before it is further mutated.

@lukhnos
lukhnos requested a review from zonble August 7, 2026 22:03
Fixes openvanilla#885

This syncs with openvanilla/fcitx5-mcbopomofo#276

UOM needs both the previous walk result and the current walk result
after node override (that is, after user manually chooses a candidate)
to make an observation, but since the nodes in a WalkResult are shared
pointers to the Node instances in the grid, WalkResult does not capture
an immutable snapshot. A new member function is introduced to enable
getting a snapshot that has a real copy of the nodes, so as to capture
the state of the grid before it is further mutated.
Comment thread Source/KeyHandler.mm
// current state. ReadingGrid::overrideCandidate() changes the state, and
// so having a simple copy of latestWalk_ (auto prevWalk = _latestWalk;)
// is NOT enough.
Formosa::Gramambular2::ReadingGrid::WalkResult prevWalk = _latestWalk.copyWithFixedNodes();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like we make a copy before doing UOM, right?

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.

Yes, the previous walk is needed before candidate override, and both the previous walk and the walk after candidate override are needed for UOM to record an observation.

@zonble
zonble merged commit 73d0379 into openvanilla:master Aug 8, 2026
10 checks passed
@lukhnos
lukhnos deleted the walk-snapshot branch August 8, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[功能問題回報] 特定字詞不會自動選中,經過多次輸入後也不會記憶

2 participants