The “title” property of, I believe, the views object, will fail to return all but the first leading underscore of a filename that has multiple underscores at the beginning of the name. For instance, one might have the following code in a userscript file:
var view = require( 'ko/views' ).current().get();
alert( view.title );
Here is an example, in which I created a new userscript file and named it “___title_test.js” (with three leading underscores, for better visibility), as seen in the first screenshot. In that script I placed the above code, and when I run the script, the alert dialog shows the front-truncated name. In the second screenshot here, you can see that the correct name is displayed in the far right panel, but the incorrect name is displayed in the tab and by the alert dialog.
At first I was reluctant to post this without first reading up on how the title property is supposed to work, but no such documentation appeared readily available. I’m probably not looking in the right place. Does anyone have any insight into why the title property is behaving this way and/or where I can read more about it and other similar properties? Thank you.
I created a plain text file, ___Text-1.txt, and in the file tab, it does display all three leading underscores. But I don’t see a way to test the main problem of the “title” property stripping all but one of the underscores, since this is a text file and not a userscript within which I could run the code.
Thank you, Carey, for that info. Yes, I had the userscript open.
At the moment, that userscript isn’t readily available since I’m testing that other issue with a clean restart, so this time I opened the text file, ___Text-1.txt, and in the console simply ran the command alert( require( 'ko/views' ).current().get().title );and all three leading underscores are displayed in the resulting text.
So this misbehavior apparently may be limited to userscripts.
The pystderr.log.txt log file did not contain anything related to syntax errors, so I simply commented out blocks of code until I found the problem – which turned out to be a silly little mistake I had made. The command you proposed worked.
As with the other property, when I have the userscript itself open and run the command alert(require("ko/views").current().basename), it too returns “_userscript_test.js”, with all but one of the leading underscores discarded.
Possibly related (but I don’t know because I’m not sure if it uses the same code), when I execute the command Clipboard - Copy View File Name, it also removes all but one of the leading underscores.
Nvm, i just realized I could just not be lazy and try this myself. Yes, the name is the same in the property, ie. all underscores are included. This is silly. Even alert(require("ko/views").current().filePath) reports the wrong filename.
Thanks for your patience @mjross but I still think this isn’t worth looking further into. I can’t imagine someone hitting this while actually working. I suspect it was a fluke you even hit it. I filed a bug regardless so we’re aware of it.
Thank you, Carey, for your help on this and for filing the bug report.
Yes, it would be unlikely that most people (i.e., normal people ) would name a file with two or more leading underscores. In my case, I started naming all of my personal userscripts with two leading underscores, so that in a (completely separate) PHP script I use for backing up all files, I could use the DOS file pattern “__*” since a single leading underscore is insufficient to distinguish them from all of the other Komodo-provided userscripts, which use underscores to separate individual words within the filename.
I’m still curious, do you know where there is any documentation for require( 'ko/views' ).current().get().title and require("ko/views").current().filePath? I’m trying to get up to speed on userscripts, and finding it a bit frustrating when trying to learn how to use properties and methods mentioned in the sample code – especially for anything related to ‘ko/views’.