Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case insensitive tags #1313

Closed
xahodo opened this issue Jan 9, 2023 · 3 comments · Fixed by #1522
Closed

Case insensitive tags #1313

xahodo opened this issue Jan 9, 2023 · 3 comments · Fixed by #1522
Labels
enhancement Request: New feature or improvement planned Note: Feature planned for a later release

Comments

@xahodo
Copy link

xahodo commented Jan 9, 2023

So, I often find that I'm frustrated with how I put tags down. Sometimes I have to enter referrals to tags down multiple times, in order to get the case right. This is, in my opinion, quite irritating. I don't memorize the exact capitalization of tags, and sometimes I do pretty dumb things with my tag names (some have case for each word, others not), and so I frequently find myself searching to figure out exactly how I had typed that particular tag out.

for example: was it "The House", or "the house", or "The house"? I prefer to be able to keep on typing without concerning myself with the case of each letter of a tag. If novelwriter could figure that out on its own, that would be great.

I would love novelwriter to ignore case for tags, as that stops quite some frustration. This could be made optional by a checkmark somewhere in the configuration of the document. Novelwriter could then keep track of all tags in lower case.

@xahodo xahodo added the enhancement Request: New feature or improvement label Jan 9, 2023
@vkbo
Copy link
Owner

vkbo commented Jan 9, 2023

I believe an auto-complete feature for tags, as mentioned in #823 would solve your issue.

@vkbo
Copy link
Owner

vkbo commented Jan 12, 2023

I've played around a little with making the tags case insensitive. The problem is that the entire tag system relies on Python dictionaries, which have case sensitive keys. So I have two options, neither of which are entirely satisfactory.

The first option is to always change tags to lower case at the initial point where they are parsed from your text files. It is a single point in the code, and it effectively causes the indexer to think all tags are lower case in the first place. The plus side to this is that it is trivial to make this feature optional. The downside to this is that all tags are then displayed in lower case in the UI in those places where the tags are shown.

The second option is to make all dictionary lookups in the registry of tags cast it to lower case before lookup, or when the data is written to the dictionary. The plus side here is that the record of defined tags can be kept in the original case, avoiding the above mentioned issue. The downside is that there are a lot of places where the tag key must be cast to lower case, effectively making it very difficult to make the feature optional as there would be a large number of if-checks against the user config.

Due to the display issue, the first option is only usable if I rewrite the index to store a display name for tags that are separate from their lookup key. It is doable, but non-trivial. The second option is only usable if I make the change permanent for all users. This may cause people to have to make changes to their projects, which is something I really try to avoid.

When I designed the tags and references system, I didn't really expect people to use phrases rather than words for tags. I thought of them much like tags on social media where they have to be written without spaces or punctuation. I never added any hard coded restrictions on this though. Personally, I've always used (upper) CamelCase for my tags, so the case is implied, which is why I never encountered any friction on this during the early days. Of course, as other users started using novelWriter, this changed. Everyone does things in their own way, but I do feel it is a little bit too late to add restrictions to how tags can be defined.

I still think the auto-complete feature is a better solution. Also because it solves other issues than just typing your tags correctly. If you have a lot of tags, it is also annoying to have to look them up if you can't remember what they were. In any case, I plan to make a number of improvements to this feature in release 2.2.

@vkbo vkbo added the planned Note: Feature planned for a later release label Sep 15, 2023
@vkbo vkbo added this to the Release 2.2 Beta 1 milestone Sep 15, 2023
@vkbo
Copy link
Owner

vkbo commented Sep 15, 2023

I've pretty much solved this, so I will include it for the 2.2 release.

@vkbo vkbo mentioned this issue Sep 15, 2023
6 tasks
@vkbo vkbo linked a pull request Sep 16, 2023 that will close this issue
6 tasks
@vkbo vkbo closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request: New feature or improvement planned Note: Feature planned for a later release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants