notepad.activateFile() doesn't work (sometimes) on "new _" files
N++ v7.5.8 x64 PS 1.2.0.0
It is observed that notepad.activateFile() sometimes seems to ignore the request when its argument is an unsaved file, e.g. "new 1", "new 2", etc.
This video (https://imgur.com/CfNdDnP) shows that I have 4 such files open, 1,3,4 and 5, but that "new 1" can't be switched to using notepad.activateFile('new 1'). The video shows that 'new 4' and 'new 5' can be switched to. No problem for 'new 3' either (but that is not in the video).
@chcg Any interest in looking at this one?
I just encountered this bug while creating a script for this inquiry: https://community.notepad-plus-plus.org/topic/24647/how-to-save-1000-fills-at-once
When using PS 2.0, notepad.activateFile('new 1') would not work, but when used with new 2, new 3, etc. it would work.
When trying with PS 3.0.16, notepad.activateFile() on ANY "new X" file did NOT work.
When I am in a state where notepad.activateFile is not working to switch to new 1 in Python Script, if I switch to NppExec console and use npp_sendmsg NPPM_SWITCHTOFILE 0 "new 1", it switches just fine. So it appears that activateFile isn't always sending the right NPPM_SWITCHTOFILE message , because the message itself is working fine
Over a year of inactivity. Time to present the obvious workaround, I guess:
def notepad_activateFile(f):
# note: we can't simply use notepad.activateFile() because of this PS bug: https://github.com/bruderstein/PythonScript/issues/105
for (pathname, buffer_id, index, view) in notepad.getFiles():
if pathname == f:
notepad.activateIndex(view, index)
break