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

Abierto
#2 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
frontend, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
0
Forks
2
Merge medio
1 d 4 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lanl/chatty

Todos los issues de lanl/chatty

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.