sieukrem / jn-npp-plugin

Plugin for Notepad++ allowing you to automate some tasks using JavaScript
https://github.com/sieukrem/jn-npp-plugin/wiki
110 stars 24 forks source link

Several MODIFYATTEMPTRO fired in column mode #25

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello, I use Clearcase SCM which checkout a file on MODIFYATTEMPTRO. In column mode the event is fired for every line and I get the several checkout dialogs. Even in single line mode sometimes the event is fired twice. As workaround I changed the clearcase.js to:

var PendingCheckouts = {};
// Add handler to catch event if user tries to modify checked in file
// and allow him to check out it
GlobalListener.addListener({ MODIFYATTEMPTRO:function(v){
    var file = getFile();
    var version = null;

    try{
    version = helperCC.Version(file);
    }catch(e){}

    if (version == null || version.IsCheckedOut)// nothing to do from point of view of ClearCase
        return;
    if ( PendingCheckouts[file] )
        return;
    PendingCheckouts[file] = 1;
    shell.run("cleardlg /checkout \""+file+'\"',0,1);
    delete PendingCheckouts[file];
}});

Is there a better way?

sieukrem commented 8 years ago

Hello, because we don't use clearcase anymore, I cannot verify this issue exactly.

I use the same principle to checkout TFS files. My Notepad++ v6.5 fires this event also in column mode once.

You changed

//from
shell.run("cleardlg /checkout \""+file+'\"'); // creates popup and runs without waiting
//to 
shell.run("cleardlg /checkout \""+file+'\"',0,1); // wait 

I think that waiting could be enough without collecting PendingCheckouts to solve this issue

ghost commented 8 years ago

Hello, you are right, waiting is enough.