MissingStyle crash on a non-markup tooltip text
**Describe the bug**
A crash on mouse hover over Query Results cell when tooltip is about to be shown when non-markup text (but markup-like) is the cell contents.
**To Reproduce**
`> harlequin -a sqlite`
Write the following query:
`select "some text [param=other_param]param label[/param] some more text so the result is long enough to show a tooltip, and some more";`
Hover the mouse cursor over the result to get a tooltip with full text.
**Expected behavior**
Tooltip with full text appears.
**Actual behavior**
A crash.
Traceback:
```$ harlequin -a sqlite
╭──────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /home/sa/.local/pipx/venvs/harlequin/lib/python3.13/site-packages/textual/screen.py:1558 in _handle_tooltip_timer │
│ │
│ 1555 │ │ │ else: │
│ 1556 │ │ │ │ tooltip.display = True │
│ 1557 │ │ │ │ tooltip.absolute_offset = self.app.mouse_position │
│ ❱ 1558 │ │ │ │ tooltip.update(tooltip_content) │
│ 1559 │ │
│ 1560 │ def _handle_mouse_move(self, event: events.MouseMove) -> None: │
│ 1561 │ │ hover_widget: Widget | None = None │
│ │
│ ╭─────────────────────────────────────────────────────────────────────────────── locals ───────────────────────────────────────────────────────────────────────────────╮ │
│ │ node = ResultsTable(id='t8793924707837') │ │
│ │ self = ScreenBase(id='_default') │ │
│ │ tooltip = Tooltip(id='textual-tooltip', classes='-textual-system') │ │
│ │ tooltip_content = <text 'some text param label some more text so the result is long enough to show a tooltip, and some more' [Span(10, 21, 'param other_param')] ''> │ │
│ │ widget = ResultsTable(id='t8793924707837') │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sa/.local/pipx/venvs/harlequin/lib/python3.13/site-packages/textual/widgets/_static.py:94 in update │
│ │
│ 91 │ │ """ │
│ 92 │ │ │
│ 93 │ │ self.__content = content │
│ ❱ 94 │ │ self.__visual = visualize(self, content, markup=self._render_markup) │
│ 95 │ │ self.refresh(layout=layout) │
│ 96 │
│ │
│ ╭─────────────────────────────────────────────────────────────────────────── locals ───────────────────────────────────────────────────────────────────────────╮ │
│ │ content = <text 'some text param label some more text so the result is long enough to show a tooltip, and some more' [Span(10, 21, 'param other_param')] ''> │ │
│ │ layout = True │ │
│ │ self = Tooltip(id='textual-tooltip', classes='-textual-system') │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sa/.local/pipx/venvs/harlequin/lib/python3.13/site-packages/textual/content.py:295 in from_rich_text │
│ │
│ 292 │ │ │ │ │ start, │
│ 293 │ │ │ │ │ end, │
│ 294 │ │ │ │ │ ( │
│ ❱ 295 │ │ │ │ │ │ Style.from_rich_style(get_style(style), ansi_theme) │
│ 296 │ │ │ │ │ │ if isinstance(style, str) │
│ 297 │ │ │ │ │ │ else Style.from_rich_style(style, ansi_theme) │
│ 298 │ │ │ │ │ ), │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────────────────────────────╮ │
│ │ ansi_theme = <rich.terminal_theme.TerminalTheme object at 0x7ff7ed3b3410> │ │
│ │ console = <console width=238 ColorSystem.TRUECOLOR> │ │
│ │ get_style = <bound method Console.get_style of <console width=238 ColorSystem.TRUECOLOR>> │ │
│ │ text = <text 'some text param label some more text so the result is long enough to show a tooltip, and some more' [Span(10, 21, 'param other_param')] ''> │ │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ /home/sa/.local/pipx/venvs/harlequin/lib/python3.13/site-packages/rich/console.py:1502 in get_style │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
MissingStyle: Failed to get style 'param other_param'; unable to parse 'param' as color; 'param' is not a valid color
```
**Additional context**
In my case `textual_fastdatatable-0.14.0` is used, if i go to `textual_fastdatatable\data_table.py:2548`, function `_set_tooltip_from_cell_at`, `cell_formatter()` function is called without `self.render_markup` propagating:
```
self._tooltip_cache[cache_key] = cell_formatter(
raw_value, null_rep=self.null_rep, col=column
)
```
If I put `render_markup=self.render_markup` like all other `cell_formatter()` calls in this class there is no crash anymore and all works as expected:
```
self._tooltip_cache[cache_key] = cell_formatter(
raw_value, null_rep=self.null_rep, col=column, render_markup=self.render_markup
)
```
But I am not familiar with that package to understand if that's the correct fix.
Also, with this change tooltip won't show correct markup anymore, always showing "raw" text output.
**What is the output of `harlequin --version`?**
```
harlequin, version 2.5.1
Installed Adapters:
- duckdb, version 2.5.1
- sqlite, version 2.5.1
```
**What database adapter are you using with Harlequin?**
In-memory sqlite
**Can you tell us more about your system?**
- Shell: bash
- Terminal: terminator
- Kernel: Linux 6.15.11-2-MANJARO
- OS of the shell: Mahjaro Linux (with latest update)
- Default locale / language for your OS/Terminal/Shell: en_US
**How did you install Harlequin?**
pipx
0 条评论