sortByDocOrder ties unplaceable refs to position zero, reordering stored phrase tokens
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- data
調査の方向性
sortByDocOrder から始めて、その呼び出し元を追跡します。特に splitPhraseAtBoundary、TokenLinkIcon の updatePhrase、PhraseBox の編集モードでの書き込みを確認してください。src/utils/segmentation.ts:105 にある対応するソートと比較し、既存の保存済み順序のアプローチについて src/utils/phrase-text.ts を確認してください。完了条件は、孤立した参照が保存済みの位置を維持し、どちらのソート経路でも位置ゼロと同順位にならないことです。
索引モデルが issue の本文から書いたものです。
説明
sortByDocOrder scores a ref the order map cannot place as 0:
(a, b) => (tokenDocOrder.get(a.tokenRef) ?? 0) - (tokenDocOrder.get(b.tokenRef) ?? 0)
so it ties with whatever sits at position zero rather than sorting to a place of its own. The sort is stable, so a stranded ref lands second, not first:
sort keys : 0, 1, 0
input : tok-a, tok-b, tok-z (tok-z stranded)
sorted : tok-a, tok-z, tok-b
Stranded refs are ordinary rather than hypothetical: Token.ref is `${sid}:${charStart}` (src/parsers/papi/bookTokenizer.ts), the book is re-tokenized from the current USJ on every load (src/hooks/useInterlinearizerBookData.ts), and the analysis persists separately, so any upstream text edit strands every ref after it. See #136.
Where it reaches stored data
splitPhraseAtBoundary (via sliceAtBoundary), the merge updatePhrase calls in TokenLinkIcon, and PhraseBox's edit-mode writes all sort through this helper before writing. A split or merge on a phrase holding a stranded member can therefore write a token list whose order no longer matches document order.
Severity is moderated by the fact that such a phrase is already half-broken: the stranded member never renders, so the reordering moves a snapshot nobody can see. It is worth fixing because it is cheap, and because the next reader will not expect it.
Fix
Decorate-sort-undecorate: give an unplaceable token the order of the last placeable one before it, so it holds its stored position instead of tying with position zero.
src/utils/phrase-text.ts already took this position by not re-sorting at all (ba23de3, #329) — the label it builds reads the phrase link's stored order, which every writer sets to document order. This issue generalizes that for the callers that must sort.
Also check src/utils/segmentation.ts:105, which repeats the same (order.get(a) ?? 0) - (order.get(b) ?? 0) pattern.
Size: S
Priority: P3 — latent. #136's re-anchoring would reduce but not remove the exposure, since unmatched links stay stale and their refs stay stranded.
- 主要言語
- TypeScript
- スター
- 2
- フォーク
- 0
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 83
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sillsdev/interlinearizer-extension のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
sillsdev/interlinearizer-extension#552 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
sillsdev/interlinearizer-extension#548 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sillsdev/interlinearizer-extension#543 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
sillsdev/interlinearizer-extension#537 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
sillsdev/interlinearizer-extension#515 ·
メンテナーはふだん 1 日以内に返信
sillsdev/interlinearizer-extension の issue をすべて見る
似ている issue
-
mobile-app
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Open-Locker/Open-Locker#352 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
leanprover-community/lean4game#589 ·
メンテナーはふだん 2 日以内に返信
-
Add: CS Action BGオープンcheck:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
unocss/unocss#5421 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信