Skip to content

notepad.activateFile() doesn't work (sometimes) on "new _" files #105

Closed

Description

@sasumner

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).

Activity

  1. sasumner commented on Jan 11, 2019

    @sasumner
    Author

    @chcg Any interest in looking at this one?

  2. alankilborn commented on Jul 1, 2023

    @alankilborn

    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.

  3. pryrt commented on Jul 1, 2023

    @pryrt
    Contributor

    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

  4. alankilborn commented on Aug 2, 2024

    @alankilborn

    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
  5. chcg commented on Oct 3, 2024

    @chcg
    Collaborator

    Issue that for PS 3.x it is not working was introduced with

    Revision: f27212c104a2a1202f397c2e026abd299152b4d0
    Author: Christian Grasser <christian.grasser@live.de>
    Date: 28.10.2022 23:21:40
    Message:
    - correct issues with long filenames as just partially fixed by N++ with https://github.com/notepad-plus-plus/notepad-plus-plus/issues/11106
    - added assert checks to testcases for the new methods with bool return values
    - removed not implemented declaration
    ----
    Modified: PythonScript/python_tests/tests/NotepadWrapperTestCase.py
    Modified: PythonScript/src/NotepadPlusWrapper.cpp
    Modified: PythonScript/src/NotepadPlusWrapper.h
    

    because handleFileNameToLongPath() is not working for unsaved files, see

    return handleFileNameToLongPath(NPPM_SWITCHTOFILE, filename);

  6. added 2 commits that reference this issue on Dec 26, 2024
  7. added a commit that references this issue on Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions