projecthamster / hamster

GNOME time tracker
http://projecthamster.org
GNU General Public License v3.0
1.08k stars 249 forks source link

Can't use hash character (#) in description field in "add activity" window #757

Open rhertzog opened 10 months ago

rhertzog commented 10 months ago

When you insert any text containing a hash (#) character in the "description" field of the "Add an activity" window, then the "Save" button is greyed out and you can't add the activity.

Note that the hash character doesn't have to be at the start of the word, so it's not only tag-words that are problematic, it's also any URL with an anchor (e.g. https://example.org/#hello).

However if you input the description with the hash character within the "cmdline" field then it is accepted... for example cmdline = 09:06 Activity@Category, https://example.org/#hello.

/cc @Flupp @GeraldJansen

rhertzog commented 10 months ago

Note that https://github.com/projecthamster/hamster/pull/755 would change the behaviour here. With this patch applied, the description can contain https://example.org/#hello (it is accepted and the save button is not greyed out) but a tag word is still not allowed in the description while it is a syntax that we decided to support.

My first implementation stripped the hash from tag words from the description while adding them into proper tags. But the general feedback was that we should not strip the hash character at all, thus we should allow tag words inside the description.

We should thus fix the behavior of this edit window to actually assign tags when we edit the description field with a tag word inside it.

GeraldJansen commented 10 months ago

Harvesting tags from the description field as one types is complicated by the need to keep three fields in sync (cmdline, description and tags). I played with this a bit, including an effort to just sync the fields on focus_out from the description field, but I didn't manage to find a satisfactory solution.

rhertzog commented 10 months ago

Yeah, it seems unreasonable to do it while typing because you would add multiple partial tags while your inputting the tag (i.e. typing #tag would add t, ta and tag). But doing it on focus_out (+ maybe once before save in case focus_out is not executed when you validate the save button with a keyboard shortcut) should be doable no?

What difficulties did you hit?

GeraldJansen commented 10 months ago

Not fully understanding when tags from the description should be added to fact.tags. The round trip check of serialization followed by parsing fails if fact.tags is not populated with harvested tags prior to making the check. Then there is the issue of re-editing tags in the description field. In this case entries in fact.tags present in the description at focus_in need to be removed from fact.tags to avoid retaining both the old and newly edited tag. I believe I also had issues of tag order before and after saving. Things just got more complicated than I had time or desire to deal with.