Merge local with external changes when file is modified by another program
-
I have a file that I am working on in two programs. Notepad++, PL/SQL Developer.
In Notepad++ I’m close to the bottom of the file, and in PLSQL Developer I’m somewhere at the top
After making a change in an external program and saving the file, notepad++ asks me
So I save some changes in an external program.
When I go back to Notepad++, it asks me if i want to reload the file. I can choose not to, but I would prefer to be asked to merge my changes and approve or deny… -
You want something here that has more “smarts” than Notepad++ can provide.
I doubt that the ComparePlus plugin could handle something like this currently, but maybe it could be made to.
Maybe that is even an ambitious “ask”. -
You want something here that has more “smarts” than Notepad++ can provide.
AFAICT the only thing that NPP needs to enable something like what @Thomas-Zito asked for is a
NPPN
notification that fires only when a file is reloaded from disk, probably namedNPPN_FILEBEFORERELOAD
(in spite of the awkward similarity in name to the existingNPPN_FILEBEFORELOAD
).If such a notification existed, a programmer could implement @Thomas-Zito’s desired functionality by responding to
NPPN_FILEBEFORERELOAD
with the following:- Load the file to be reloaded (call it
fileToReload
from disk, and put its contents in a new temp buffer (call itfileOnDisk
) - Use ComparePlus to compare the
fileOnDisk
withfileToReload
- Probably cancel the compare and empty and close
fileOnDisk
in response tofileToReload
being saved.
The overhead of a new
NPPN
is pretty low, both in terms of new code and performance overhead, so I imagine that Don Ho might be receptive to this idea. I’m not going to submit a new issue myself, but others are more than welcome to. - Load the file to be reloaded (call it
-
@Thomas-Zito If you want to put in a feature request along the lines of what Mark said, see some instructions on how to do it HERE.
-
@Mark-Olson said in Merge local with external changes when file is modified by another program:
You want something here that has more “smarts” than Notepad++ can provide.
AFAICT the only thing that NPP needs to enable something like what @Thomas-Zito asked for is a
NPPN
notification that fires only when a file is reloaded from disk, probably namedNPPN_FILEBEFORERELOAD
(in spite of the awkward similarity in name to the existingNPPN_FILEBEFORELOAD
).If such a notification existed, a programmer could implement @Thomas-Zito’s desired functionality by responding to
NPPN_FILEBEFORERELOAD
with the following:- Load the file to be reloaded (call it
fileToReload
from disk, and put its contents in a new temp buffer (call itfileOnDisk
) - Use ComparePlus to compare the
fileOnDisk
withfileToReload
- Probably cancel the compare and empty and close
fileOnDisk
in response tofileToReload
being saved.
The overhead of a new
NPPN
is pretty low, both in terms of new code and performance overhead, so I imagine that Don Ho might be receptive to this idea. I’m not going to submit a new issue myself, but others are more than welcome to.I think the hard part of this is step 2. That amounts to “add funtionality to ComparePlus — or create a separate, dedicated plugin — that can compare the current, edited version of a file to the version on disk and provide an interface through which the user can resolve conflicts.”
Having done that, you really don’t need to modify Notepad++: you just need to answer “No” to that pop-up and then invoke the plugin. The NPPN message could allow the plugin to intercept this condition, but as far I know, no current NPPN message processes a return value; unless this one were different, or an NPPM message were added that would be allowed within the NPPN processing, there would be no way to tell Notepad++ to skip the dialog. (If the dialog came first, there would be no reload to trigger the NPPN message if the user selected “No,” and if the user selected “Yes” there would, again, have to be some way to tell Notepad++ not to do the reload from disk after all, because the plugin would process it instead.)
So my suggestion — since aside from one extra step by the user (invoking a plugin command) this could be accomplished without modifying Notepad++ — is that the first step should be to find someone willing and able to write that plugin command. When and if that actually happens, consider asking for a change in Notepad++ to make it a little bit easier to use.
- Load the file to be reloaded (call it
-
Something else should be noted which may have escaped the original poster.
None of the ideas discussed thus far retain a copy of the original file, before either Notepad++ or the external program changed it. That means you won’t be choosing to merge changes from two sources; you’ll be comparing your edits to the file as edited in the external program, with no way to distinguish edits in the external program from text that was already in the file before you started editing in either program.
This might not be what was imagined.
-
@Coises said in Merge local with external changes when file is modified by another program:
I think the hard part of this is step 2. That amounts to “add funtionality to ComparePlus — or create a separate, dedicated plugin — that can compare the current, edited version of a file to the version on disk and provide an interface through which the user can resolve conflicts.”
Doesn’t the existing action Diff since Last Save essentially do that already? It compares the value in Notepad++ to the value on disk, and allows you to resolve conflicts; how is that not what you just described?
-
@PeterJones said in Merge local with external changes when file is modified by another program:
Doesn’t the existing action Diff since Last Save essentially do that already? It compares the value in Notepad++ to the value on disk, and allows you to resolve conflicts; how is that not what you just described?
I don’t use ComparePlus and don’t really know much at all about it. Without really thinking about it, I assumed (and we all know what comes of that) that if ComparePlus could already do such a thing, a solution using that capability would have been proposed.
-
@PeterJones said in Merge local with external changes when file is modified by another program:
Doesn’t the existing action Diff since Last Save essentially do that already?
I can confirm that this is in fact exactly what
Diff since Last Save
in ComparePlus does, making it totally unnecessary to create anNPPN_FILEBEFORERELOAD
notification or do anything I suggested in my above post.