GeopJr / Tuba

Browse the Fediverse
https://tuba.geopjr.dev/
GNU General Public License v3.0
506 stars 55 forks source link

[Bug]: Hashtags autocompletion / keyword popularity statistics popover breaks when editing a hashtag that is followed by regular words #920

Closed nekohayo closed 3 weeks ago

nekohayo commented 2 months ago

Describe the bug

This is the 2024 Edition™ follow-up to #660 :)

The hashtags autocompletion+stats widget can still break under some circumstances: It does not like me changing my mind and using backspace + rewriting an existing hashtag in a draft. This occurs frequently when trying to iteratively figure out the best hashtag to use while drafting.

Symptoms (as observed in the video below):

Steps To Reproduce

See demonstration video below. Basically:

  1. Type out a hashtag
  2. Type some non-hashtag words afterwards
  3. Go back to the end of your hashtag word, backspace and try to change the hashtag to something else

Logs and/or Screenshots

breaking tuba autocompletion by editing, 2024 edition.webm

Instance Backend

Mastodon

Operating System

Fedora 39

Package

Flatpak

Troubleshooting information

os: GNOME 46 (Flatpak runtime) prefix: /app flatpak: true version: 0.7.2 (production) gtk: 4.14.1 (4.14.1) libadwaita: 1.5.0 (1.5.0) libsoup: 3.4.4 (3.4.4) libgtksourceview: 5.12.0 (5.12.0)

Additional Context

No response

nekohayo commented 2 months ago

"overwriting" (i.e. ctrl+shift+left to select the whole word, then just type a replacement) also breaks in new and exciting ways ;)

breaking tuba autocompletion by editing, 2024 edition, part 2.webm

GeopJr commented 2 months ago

What did past me mean by this:

        // If end is ':', everything until
        // a newline will be treated as a word
        if (end.get_char () != ':')
            end.forward_word_end ();
GeopJr commented 2 months ago

the comment is wrong, the comment doesnt even tell me why

GeopJr commented 2 months ago

The main issue is that i'm fighting both the completionprovider and pango, pango treats foo#bar as 2 words, foo and bar, supposedly # being the word break then completionprovider bounds are from the pango word start until the cursor, so if you have abc#defgh and your cursor is between f and g, it will return def :weary:

I'm going to rewrite this again, but any input would be appreciated: We'll get the word bounds, then move backwards until we find a space, then move one forward and check if it's a provider trigger e.g. #, @, :. Then from the end, move forward until we find a space (and move one back) or word end. That will return the full word.

When replacing, we'll add a space at the end if there's not one already

Hopefully it won't have too much of a performance impact

GeopJr commented 3 weeks ago

Please try #1003 to see if this issue and #779 and any other papercuts you have with the auto complete are fixed

I do NOT like it at all :weary: Please tell me if you notice any performance regressions while typing. Having to fight both pango and sourceview leaves me with having to detect word bounds and triggers every time the text input changes.

nekohayo commented 6 days ago

The fix seems to work very well in practice; I haven't tested on my AMD graphics desktop yet, but at least on Intel Kabylake graphics & CPU, it feels fast, no noticeable slowdown whether I'm typing slowly or mashing keys.