lrstanley / bubblezone

helper utility for BubbleTea, allowing easy mouse event tracking
https://pkg.go.dev/github.com/lrstanley/bubblezone
MIT License
537 stars 17 forks source link

bug: Identifiers show up during list filtering #1

Closed gabe565 closed 2 years ago

gabe565 commented 2 years ago

🌧 Describe the problem

Really impressed with this project, but am coming across an issue with list filtering. When filtering a list with bubblezone, parts of the identifier escape sequences are output in item titles.

⛅ Expected behavior

I would expect list characters to be stripped during filtering.

🔄 Minimal reproduction

  1. Run list-default example.
  2. Type in a filter that matches some items (for example, /ra).
  3. Parts of identifiers are displayed at beginning of item titles.

💠 Version: bubblezone

3cb8c52f6a8f54cf189c461191b1ff5d97431148

🖥 Version: Operating system

macos

⚙ Additional context

Screenshot

image

Other

Would the code that adds the underline be stripping out the escape sequences? It seems like the underline is being added in the wrong place, causing a break in the escape sequences which results in them not being stripped from output.

Examples with escape sequences

Regular title with bubblezone: │ Raspberry Pi’s Title during filter with bubblezone: [1001ZRaspberry Pi’s Title during filter without bubblezone: Raspberry Pi’s

Thank you!

🤝 Requirements

lrstanley commented 2 years ago

Pushed some minor changes in https://github.com/lrstanley/bubblezone/commit/e408d1dc3890b323ffead8233d3d6075aad3813d to improve that experience. Unfortunately, the list bubble isn't very extensible, and has a few odd quirks that make it difficult to customize. It uses indexes to change selected items, rather than relying on some ID, which means extra logic has to be taken into consideration for what items are visible, vs which aren't. Additionally, it looks as though when filtering, and it showing matching results, those results aren't propagated to item.VisibleRows(). This means that using SetItem() doesn't seem to do anything, because it thinks there are no visible rows.

I've fixed the example so it doesn't break, though it looks like the underlying issue is with bubbles itself. It looks like filtered results aren't 1:1 on top of the normal title boxes, so characters are left over from the previous view.