Did I break NPP?
-
Sorry for the title, Peter, it was just kind of seemed the way to ask it, but in hindsight, yes, you’re right. However, to answer your question, as both screenshots below will show, they both have the same headers, but your explanation would also explain it.
My problem, besides that, is after I took out the “offending” modules, the auto Completion file refused to work. I’ll inspect it further, maybe a transient character somewhere left over from the swapping, but…this behavior made me think that maybe it just broke it. :)
Lee
-
@lycan-thrope
Okay, update. Now ALL of my text files formatted like .xml are showing up syntax highlighted. :-( I broke it. :-)Anyway, I found the errant character in my auto completion file. It was another double
<<
at the start of a tag, but it wasn’t one of the tags I was messing with so I’m starting to wonder if frequent copy/paste ops tend to freak the system out. Reason is I’m swapping these “test” modules of autocompletion in and out, shutting down, restarting in admin mode again and then testing them, so I can avoid having to look through all the code that might cause the problem, so I’m going in and out of NPP frequently and I can’t explain how that errant angle bracket got in a KeyWord module 1-2 down from where I was working at. ::shrug::Other than that, you’re right, that .xml code inside .txt files is now, apparently permanent for me it appears.
Lee
-
@lycan-thrope said in Did I break NPP?:
Now ALL of my text files formatted like .xml are showing up syntax highlighted. :-( I broke it. :-)
No. As I said, starting a file with the
<?xml...?>
is a trigger to Notepad++ to interpret any file, even if it is saved as .txt, as an XML file. I wasn’t sure of the details last night, but I just ran some experiments:When you create and save a new file as a text file, Notepad++ keeps it as a “Normal text file” while you’re editing it: including saving the state and if you exit Notepad++ completely while it’s remembering sessions, when you re-run Notepad++ with the same session, it still shows as “Normal text file”.
However, if you close the file (File>Close) and then reload the file (File>Open or File>Restore Recent Closed File), Notepad++ will see the
<?xml...?>
trigger and will override the default*.txt
=> NormalTextFile mapping with the start=<?xml...?>
=> XML File mapping. If you do Language>None(Normal Text), it will go back to Normal Text for the current session (even if you restart Notepad++)… but as soon as you close the file, then Notepad++ forgets the setting for the file, and on the next Open/Restore, it will see the trigger during load and interpret that file as XML.If I delete the
<?xml ...?>
line, save the*.txt
file, close the file, then Open/Restore, Notepad++ no longer sees the trigger, and applies the*.txt
=> NormalTextFile mapping as expected.–
Two things, looking at the screenshots of your XML files:
- The second file has a
+
after the<NotepadPlus>
opening tag. That may confuse Notepad++ - See StackOverflow:“Can literal angle brackets be used in quoted attribute value strings”, so your LOWERCASE.txt with
<oRef>
in the attribute value is not valid XML. It should be<oRef>
inside the attribute value (or inside a tag pair, for that matter), because<
and>
are special characters inside XML, and need to be escaped except when using them as part of tag syntax.
You might consider grabbing the XML Tools plugin, because it can check to make sure that your file is valid XML, and should point out things like un-escaped special characters.
- The second file has a
-
Thanks for checking into that. You are probably right, as I’ve had these files open in the editor for quite a few days, but it only changed after my auto complete file failed from that errant character (I’m guessing) in it. What you propose makes sense I think.
As for the
+
, I have no idea how that got there. I didn’t put it there, which brings me back to the possiblity that there is something going on where spurious characters are being inserted that (AFAIK), I didn’t introduce.The
< >
should be an easy fix then with a search/replace, but here’s the thing… even though the XML Tools flagged them, that’s the only way I knew they weretoxic
, but they DO work, as is, as long as the .xml tags are paired properly outside of quotes, the angle brackets are inside of quoted areas. This may be a flaw in the parser, as I agree, if they are illegal, they should be flagged somehow before I’ve created 5,000 plus lines of them. :-)Thanks for you informative expertise. I’ll try and more appropriately title any futher subjects. :-)
Lee
-
@lycan-thrope said in Did I break NPP?:
which brings me back to the possibility that there is something going on where spurious characters are being inserted that (AFAIK), I didn’t introduce.
My guess is fat-finger syndrome / PEBKAC (typing characters you don’t notice, or not selecting the text you thought you did when copy/pasting, or having macros that do more than you think they do). You said in an earlier post, “I’m starting to wonder if frequent copy/paste ops tend to freak the system out”, and I disagree with that assessment vehemently. Copy/paste is simple for a text editor to implement, and I have never seen copy/paste get “freaked out” just by using it a bunch; I use tons of copy/paste, and never have problems with it. My guess is user-error, not a problem with the software.
This may be a flaw in the parser,
Nope.
Just like for C++ or JS or any other programming language, the syntax highlighter cannot be expected to behave identically to a compiler or official language-understanding tool (ie, it cannot show you all compiler errors and runtime errors and logic bugs and …) – it has a different purpose in life, namely, to highlight keywords and allow code folding. That’s why there are plugins, like XML Tools, to add features that shouldn’t be expected in a default syntax highlighter.
-
@peterjones said in Did I break NPP?:
My guess is fat-finger syndrome / PEBKAC (typing characters you don’t notice, or not selecting the text you thought you did when copy/pasting, or having macros that do more than you think they do).
Well, I’m most definitely guilty of that, but I also suffer from “worn-out laptop keyboarditis” as well. :-( Not every key wants to press since I am a touch typist so if you see a lot of typos, most likely I was going to fast for the keyboard and even though I know I hit the key, it doesn’t always make it in to the buffer. :-(
I can concede your points are possible, though. Most problems are user related so I’m not going to argue that point, unless I can realiably duplicate it, with pictures. :-) The syntax highlighting is the tool to find out if you’re doing things inappropriately, which is basically it’s reason for living, so although it’s not perfect, nothing is, I can hope that if it’s not supposed to allow illegal characters, regardless of where they appear, that at the least they would color funny so that you can catch it.
As for the “simple search/replace”…yeah, right. Back to the Regex. :-) LOL
Lee
-
@peterjones said in Did I break NPP?:
starting a file with the <?xml…?> is a trigger to Notepad++ to interpret any file, even if it is saved as .txt, as an XML file
Indeed.
This mechanism is seen, in general, starting HERE.
And, specifically for the xml case, HERE.
-
Those aspects of NPP (Scintlla) at least for now, are beyond my pay grade. :-). Unless they’re handing out free Visual Studio compilers and tools, or I take the time to delve into Python, it’s not in my wheelhouse at the moment.
Back to regex. I was trying to write a regex to encompass all my sins, but I get the feeling that Search & Replace is going to have to be done one variation at a time. Would that be a realistic assessment? I can’t do a catch all using the brackets only without catching all the tags, and as soon as I use a capture group it starts getting funcky, so I’m guessing that the S/R is meant to be used piecemeal in this kind of situation.
Lee
-
@lycan-thrope
Forgot, otherwise, my option since it works as is, is to use it as is and fix it later and update the files later for anyone that wants to update them after I get the angle brackets out of the equation. :sigh:: So much for a “quick” project. :-)Lee
-
@lycan-thrope
Yep, that was the ticket. Made up a couple of patterns for the more numerous and simple one’s, and then ran the XML Tools checker to finish cleaning up the more difficult ones and now the auto completion file is done, so I can now clean up the files that have more modules to go into the auto completion file before adding them in.Onward I go. :-)
Lee
-
@lycan-thrope said in Did I break NPP?:
Unless they’re handing out free Visual Studio compilers and tools,
They do, see here.
-
@lycan-thrope said in Did I break NPP?:
Those aspects of NPP (Scintlla) at least for now, are beyond my pay grade. :-). Unless they’re handing out free Visual Studio compilers and tools, or I take the time to delve into Python, it’s not in my wheelhouse at the moment.
I’m not sure what you’re talking about. What I mentioned doesn’t have anything to do with Scintilla. And you don’t need to build the code to benefit from looking at a project’s source code to infer behavior.
I merely pointed out in the source code for Notepad++ where one can see what it does to override extension-based file type detection because a string is found to be present in the file.
I did this because of what Peter mentioned, and I thought it a semi-interesting topic because the behavior is not at all obvious, and it is curious to see what other strings generate this behavior besides the one for xml.
-
@ekopalypse said in Did I break NPP?:
They do, see here
Interesting, I’ll have to check out the English website, but thanks for that info. Not sure I’ll be head banging into that just right now, but nice to know.
Lee
-
Thanks. I appeciated, and actually understood the information you were linking me to. I guess my humorous response wasn’t taken the way it was intended, so… sorry . :-)
But I definitely agree with your observation, that indeed, it is not at all obvious, which is kind of why my answer was a “flippant” so I apologize if you didn’t understand that I was agreeing with you. :-)
Lee