Syntax highlighting: works for a time, then (irreproducibly) "bleeds", only restarting npp fixes it
-
For years I had no problems with syntax highlighting in a user defined language. A few months ago I had to re-install npp and in v7.9.1 and v7.9.3 I have the following behaviour: for a certain time everything behaves as normal. After a while, seemingly randomly, part of my code is coloured as a comment (code which is not a comment).
Sometimes it is only the line that I am editing, sometimes it is from the cursor to the next /* in my code.
The only remedy I found is exiting npp, restarting it and typically within half an hour the problem reoccurs.
Has anyone experienced the same? Could it be caused by the user defined language?
-
Not exactly as you described, but kind of similar.
For me, the problem was that my code had different EOLs, namely Windows CRLF and Linux LF.
Once I made sure it was the same, I had no more problems. -
Thanx for the suggestion. I checked it, but it seems that I only use Windows CRLF in my code.
-
hmm … sorry, obvious question, did the udl change as well?
Mind sharing the UDL and some sample code? -
@El-Greco said in Syntax highlighting: works for a time, then (irreproducibly) "bleeds", only restarting npp fixes it:
Could it be caused by the user defined language?
Yes, of course it could be - maybe a bug/feature!?
-
I have had this problem for a while with AutoHotkey UDL and only recently tried to fix it. Going to the UDL Dialog and inserting ((EOL)) in the Close: box for single line comments seems to have helped - though I have only been using it for a day or two since the change. But you can see in the Notepad++ margin a fold line appear or disappear depending on the setting. Also using (( " EOL )) in the Close: box for text on the Operators & Delimiters tab may also help though I haven’t tried this.
If this all fails I found the Ctrl+R (Reload from Disk) corrected the highlighting. -
@ludamo-0
Very interesting suggestion, I have implemented it and so far, so good…!
(although according to Murphy’s Law it is dangerous to mention it)
I will try it now for a week and then report about it here. -
@El-Greco
Well, using ((EOL)) seems to improve it, but the issue still remains (although the behaviour is slightly different). I wonder, I am using the same UDL as before, with a much older version of npp (v6.x.y, I forgot which one) without ever having this problem. This problem started when I updated to npp v7.9.1 and v7.9.3 behaves the same.
The CTRL+R shortcut is a good one, then at least I can reset the view. -
Well I sympathize with you, my AutoHotkey folding was all over the place as well as the original issue and so I tried a few random things without much success BUT I did have some improvement / success with doing 2 last things:
- moving my userDefinedLang.xml file from …AppData\Roaming\Notepad++\ (I think - although it could have been in C:\Program Files\Notepad++) to …AppData\Roaming\Notepad++\userDefineLangs\ (as well as splitting the individual UDLs into separate files - I had 2 in the original file)
- Unselecting “Allow folding in comments” then restarting Notepad++ then Selecting it again.
I haven’t used it enough since to say whether things are cured but here’s hoping.
-
Since experimenting further with the AutohotKey UDL I have found that this syntax “bleeding” can be limited / minimised / corrected by adding a space to the end of lines (I normally am a heavy user of tabs) especially those lines which seem to end a certain type of highlighting e.g. comments or lines with delimited strings in them.
I also made another discovery, that a tab can be used as a delimiter in UDL. You can enter it by pressing Control+Tab between 2 spaces e.g. ((space tab space EOL)).
-