Tuba
Tuba copied to clipboard
[Bug]: Hashtags autocompletion / keyword popularity statistics popover breaks when editing a hashtag that is followed by regular words
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):
- Most of the time the autocompletion stats widget does not show up at all
- Sometimes it also erronously parses adjacent words into it
Steps To Reproduce
See demonstration video below. Basically:
- Type out a hashtag
- Type some non-hashtag words afterwards
- 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
"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
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 ();
the comment is wrong, the comment doesnt even tell me why
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
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.
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.