What triggers a ModificationAttemptListener?

I'm trying to make a change to my VIM plugin to work better with version control systems (VCS).

Up until now, if a user enters a VIM command that would modify a read-only file I simply beep and eat the command.

What I would like to do is let the command go through and have the underlying VCS system prompt the user if the file should be checked out.

This works fine if I attempt to insert some text.

However, if I issue a VIM command, say to delete a line of text, nothing happens. The line is not deleted and the user is not prompted to checkout the file.

The VIM plugin ultimately calls 'editor.getDocument().deleteText(...)

So what in IDEA actually triggers a call to the ModificationAttemptListener in a typical VCS plugin?

Thanks,
Rick

3 comments
Comment actions Permalink

Does it create multiple physical labels? What does the array contain?
Is it returning all the labels before (after?) insertion?
Intuitively I would expect it to return the label I just created.

Jacques

0
Comment actions Permalink

Sorry for the cross post. C&P error ;-(

Back to answering your question from my little knowledge:
I believe that nothing checks for that under the API (In my opinion it should be).
What I did in the JUnitTestPlugin in case the file is not writable is to fire the ModificationAttemptEvent OUTSIDE of a write action (Being outside is very important!!! see http://www.intellij.net/forums/thread.jsp?forum=23&thread=45764 for more info on the subject), then recheck for writability


As the underlying VCS could have modified the file on check out, you need to make sure that you are still at the same logical position in the file after invoking this.

Good luck

Jacques

0
Comment actions Permalink

Related SCR:
http://www.intellij.net/tracker/idea/viewSCR?publicId=3671 Do not abort action if ModificationAttemptListener make target file writable

0

Please sign in to leave a comment.