Community
    • 登入

    Symlinks to file don't give refresh dialogue when outside program modifies them

    已排程 已置頂 已鎖定 已移動 Help wanted · · · – – – · · ·
    4 貼文 2 Posters 526 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • Andrew SchultzA
      Andrew Schultz
      最後由 Andrew Schultz 編輯

      In the old versions of Notepad++, I could create a file in Windows and a symlink to that file, and if I changed one or the other, it would ask if I wanted to refresh both. This was a bit awkward, but it was helpful.

      I wrote a script that looked through notepad++ daily for files that might be duplicated, e.g. I had A opened and B, and A was a symlink to B.

      I recently updated (from 6.8 to 7.8 … a big jump) and while a lot of new features are great, I have a small problem. I don’t see any immediate way to stop using symlinks, and if I

      mklink a.txt b.txt

      And I change a.txt, then b.txt will register as changed.

      But if I change b.txt, a.txt will register as changed.

      Also, if I write an outside script to change a.txt or b.txt, Notepad++ registers b.txt is changed, but not a.txt. This is a problem, as I automate a lot of changes in some text files.

      Now I can be careful with which file I open. I can even close and open files regularly. I should probably close a lot of my excess tabs.

      But I am wondering if I am missing an option to set, so that when we look if a.txt is changed, we look for if its symbolic links have changed.

      I have tried settings:preferences:misc:auto-detect, but none of the option changes I tried worked.

      It looks like I need to keep my symlinks, because a program I use needs them in a \program files directory, but I want to use \users\andrew\documents\github\my_project for source control.

      Is there something I’m overlooking in Notepad++ or symlinks in general, or do I need to revisit how I handle my symlinked files? Thanks for any and all help!

      PeterJonesP 1 條回覆 最後回覆 回覆 引用 0
      • PeterJonesP
        PeterJones @Andrew Schultz
        最後由 編輯

        @Andrew-Schultz ,

        Sorry, not an expert on symlinks, but since no one else has replied…

        As far as I know, there aren’t any options available to Notepad++ configurations to affect how symlinks are handled. As far as I know, for recognizing external changes, Notepad++ relies on the timestamp on the file it’s editing, and I would think that unless a.txt’s timestamp is updated, Notepad++ wouldn’t be able to recognize it was changed. And the change of the timestamp would be something required to be initiated by the external process. And no, I don’t know how that’s accomplished. Sorry.

        or do I need to revisit how I handle my symlinked files?

        My guess is yes, that would be your best choice. Personally, I would only open one of the two files in a symlinked pair; if they always both have the same contents, why bother leaving both open?

        Anyway, sorry I wasn’t more help, but given the lack of response, I don’t know that you’ll get a better answer.

        Andrew SchultzA 1 條回覆 最後回覆 回覆 引用 2
        • Andrew SchultzA
          Andrew Schultz @PeterJones
          最後由 編輯

          @PeterJones thanks. How Notepad handles things makes sense, probably more than the old way, but the old way was more convenient for me.

          My scripts point to the symlinks outside my git directories, because it is simpler that way, so I will see about updating them. Git doesn’t let you check in symlinks.

          Hard links are also a possibility. So there are solutions. But I’m disappointed there isn’t an option to follow symlinks when looking for if a file changed.

          Andrew SchultzA 1 條回覆 最後回覆 回覆 引用 0
          • Andrew SchultzA
            Andrew Schultz @Andrew Schultz
            最後由 Andrew Schultz 編輯

            @Andrew-Schultz well, double posting is generally a bit tacky, but here, I figured what I was doing wrong.

            I had switched to Windows 10 and this may have altered the behavior of start.exe, which I used to spawn notepad for stuff like python files.

            Notepad++ actually does, by default, open symlinks. If I open a .txt file that symlinks to another, it shows the linked-to file.

            With link-from.txt linking to link-to.txt, this opens up the file linked from:

            start "" "c:\program files\notepad++\notepad.exe" "link-from.txt"
            

            This opens up the file linked to:

            start "c:\program files\notepad++\notepad.exe" "link-from.txt"
            

            I suppose I can complain about windows batch files a bit if I want, but … this looks like something notepad++ can’t be expected to handle, but I can, pretty easily.

            Hopefully what I found can save someone else a bit of time.

            1 條回覆 最後回覆 回覆 引用 2
            • 第一個貼文
              最後的貼文
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors