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
"Highlight multiple spaces" does not work on line breaks #1043
Comments
😆
Hmm, interesting. I've never noticed this. It has something to do with how the Qt library renders the text. The highlighting is handled there. I just tell it to look for the spaces with a regex. I'll play around with it to see if I can make it detect them also when wrapping.
Nah, it should say "redundant" spaces instead. As for the trailing space, it is intended to detect them as it does. Even during typing. I could perhaps make it either ignore it if the cursor is parked next to it, or make it only highlight them if they are after punctuation. |
I spent some time looking at the source code of Qt last night, and the class that actually draws the lines on the GUI after the wrapping has been applied seems to subtract the room taken up by spaces. You can test this yourself by adding multiple spaces to the end of a wrapped line. Even if you enable the "show tabs and spaces" feature, which is Qt's own feature, they are hidden. In other words: there is no way for me to control this behaviour from Python. I've considered replacing this highlight feature with a general cleanup tool that can do a lot of different cleanup tasks on the text. This could include removing redundant spaces. I'll make a new feature issue on this. I'll fix the label on the Preferences dialog though, so it's more accurate. |
So what was the fix for this issue? I noticed it happening recently on Is it something you can report to Qt and wait for a fix? |
It is not fixable in novelWriter. It is also not a bug in Qt, so I doubt they will change anything. It would cause problems with their word wrapping implementation. The feature to highlight multi-spaces will have to live with this limitation until I come up with a better feature. I have plans to implement a different feature to alert the writer to issues in the text. It's been discussed as part of issue #515 in this comment. Edit: As mentioned in my comment further up this thread, even Qt's own feature to show white spaces has this limitation. |
Hi, me again.
When an automatic (not a hard) line break occurs at two consecutive spaces, they are not highlighted. This has me frequently go back during editing and check if I have accidentally inserted an additional space by inserting a temporary hard line break.
Multiple spaces at an automatic line break (shown at the cursor):
Spaces not shown when text is selected. This doesn't feel like a bug, just the way text is handled, but is maybe the reason why multiple spaces aren't highlighted?
That said, I usually don't have the feature turned on anyway, because it highlights a single space as soon as I typed it. Of course, because it thinks I'm at the end of a line and spaces at the end of a line are errorenous. But it's a single space, and the feature is about highlighting multiple spaces. 🤷
Perhaps the feature could be split in two:
The text was updated successfully, but these errors were encountered: