Search highlighting shows stray backslashes, misses bracketed matches, and can crash

Aperta
#2 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
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
frontend, testing

Direzione di ricerca

Start in src/chatty/ui/widgets.py at MessageWidget._apply_highlight (around line 163) and read issue #1, which is linked as related work. Check how the search handler calls this method and run the existing search/highlighting tests. Done means highlights use Content.stylize("reverse", start, end), bracketed and backslash-adjacent matches work, and searching no longer crashes.

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

Descrizione

area: ui bug crash markup

MessageWidget._apply_highlight (src/chatty/ui/widgets.py:163) tries to protect brackets with text.replace("[", r"\[").replace("]", r"\]") before inserting [reverse]...[/reverse] around each match. This is wrong in three ways:

  1. \] is not a Textual escape, so it shows as a literal backslash. Searching hiv in See [1.3] and HIV displays See [1.3\] and HIV.
  2. Escaping happens before the search, so match positions refer to the escaped text. Searching [1.3] counts the message as a match but highlights nothing.
  3. A match right after a backslash escapes the opening tag. Searching b in a\b produces a\[reverse]b[/reverse], and searching ] in any message with brackets produces the same pattern. Both raise MarkupError: auto closing tag ('[/]') has nothing to close from the search handler, and the app exits.

Fix: build the highlighted text as Content and apply Content.stylize("reverse", start, end) at the match positions, which never parses the message as markup. Fix this together with #1, which removes markup parsing from the rest of MessageWidget.

Lingua principale
Python
Stelle
0
Fork
2
Merge medio
1g 4h
PR unite (30g)
13

Preparare l'ambiente

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 lanl/chatty

Tutte le issue di lanl/chatty

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.