Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

sortByDocOrder ties unplaceable refs to position zero, reordering stored phrase tokens

Aperta
#330 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
data

Direzione di ricerca

Inizia da sortByDocOrder e segui i suoi chiamanti, in particolare splitPhraseAtBoundary, updatePhrase in TokenLinkIcon e le scritture in modalità di modifica di PhraseBox. Confronta l’ordinamento corrispondente in src/utils/segmentation.ts:105 ed esamina src/utils/phrase-text.ts per l’approccio esistente basato sull’ordine memorizzato. Il lavoro è completato quando i riferimenti isolati mantengono la loro posizione memorizzata senza andare a pari con la posizione zero in nessuno dei due percorsi di ordinamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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.

Lingua principale
TypeScript
Stelle
2
Fork
0
Merge medio
2g 3h
PR unite (30g)
46

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sillsdev/interlinearizer-extension

Tutte le issue di sillsdev/interlinearizer-extension

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.