On Thu, Nov 13, 2008 at 9:55 PM, Xavier de Gaye <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 12, 2008 at 10:45 PM, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
>>
>> Xavier de Gaye wrote:
>>
>>> >> OK. So a ":quit" will not cause a "killed" event.
>>> >
>>> > ...unless, maybe, the result is to exit Vim? (But this case ought to be
>>> > covered by BufDelete.)
>>>
>>> Actually, when ":quit" causes Vim to exit, "killed" events are
>>> currently sent for each buffer known by netbeans, before the final
>>> "disconnect" event that warns the application that netbeans is
>>> terminating.
>>
>> Yes, I was thinking of ":quit" just closing a buffer, possibly unloading
>> it. It's also possible that 'bufhidden' is set to "delete" or "wipe".
>> So generally: unloading doesn't trigger killed, deleting or wiping out
>> the buffer does.
>
> Right.
> I will propose a patch that sends a "killed" events for all these
> cases, plus for backward compatibily, when processing a
> "stopDocumentListen" netbeans command and the buffer is marked as a
> "netbeansBuffer" buffer.
The attached patch is based on Vim subversion revision 1264, Vim
version 7.2.49.
Problem: "killed" netbeans events are not handled correctly.
Solution: A "killed" netbeans event is sent when the buffer is deleted
or wiped out (in this case, the netbeans annotations in this buffer
have been removed). A user can still remove a sign with the command
":sign unplace" and this does not trigger a "killed" event.
Tests run on Vim 7.2.49:
Two buffers 'foo' and 'bar' displayed in split windows with a
netbeans annotations placed on buffer 'foo'.
A test is pass if a killed event is sent when (and only when) the
Vim signs are removed.
killed evt Vim signs test
removed
quit No No Ok
quit (bufhidden=delete) No Yes Failed
quit (bufhidden=wipe) No Yes Failed
bunload foo Yes No Failed
bdelete foo Yes Yes Ok
bwipeout foo Yes. Yes Ok
qall Yes Yes Ok
stopDocumentListen Yes Yes Ok
The last test has been run with 'clewn -d' and the commands:
@ bufId netbeansBuffer T
@ bufId stopDocumentListen
Tests run with the attached patch applied:
killed evt Vim signs status
removed
quit foo No No Ok
quit foo (bh=delete) Yes Yes Ok
quit foo (bh=wipe) Yes Yes Ok
bunload foo No No Ok
bdlete foo Yes Yes Ok
bwipeout foo Yes Yes Ok
qall Yes Yes Ok
stopDocumentListen Yes Yes Ok
Xavier
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: runtime/doc/netbeans.txt
===================================================================
--- runtime/doc/netbeans.txt (revision 1264)
+++ runtime/doc/netbeans.txt (working copy)
@@ -722,8 +722,10 @@
of the cursor.
New in version 2.1.
-killed A file was closed by the user. Only for files that have been
- assigned a number by the IDE.
+killed A file was deleted or wiped out by the user and the buffer
+ annotations have been removed. The bufID number for this
+ buffer has become invalid. Only for files that have been
+ assigned a bufID number by the IDE.
newDotAndMark off off
Reports the position of the cursor being at "off" bytes into
Index: src/netbeans.c
===================================================================
--- src/netbeans.c (revision 1264)
+++ src/netbeans.c (working copy)
@@ -2924,44 +2924,26 @@
}
/*
- * Tell netbeans a file was closed.
+ * Tell netbeans that a file was deleted or wiped out.
*/
void
-netbeans_file_closed(buf_T *bufp)
+netbeans_file_killed(buf_T *bufp)
{
int bufno = nb_getbufno(bufp);
nbbuf_T *nbbuf = nb_get_buf(bufno);
char buffer[2*MAXPATHL];
- if (!haveConnection || bufno < 0)
+ if (!haveConnection || bufno == -1)
return;
- if (!netbeansCloseFile)
- {
- nbdebug(("Ignoring file_closed for %s. File was closed from IDE\n",
- bufp->b_ffname));
- return;
- }
+ nbdebug(("netbeans_file_killed:\n"));
+ nbdebug((" Killing bufno: %d", bufno));
- nbdebug(("netbeans_file_closed:\n"));
- nbdebug((" Closing bufno: %d", bufno));
- if (curbuf != NULL && curbuf != bufp)
- {
- nbdebug((" Curbuf bufno: %d\n", nb_getbufno(curbuf)));
- }
- else if (curbuf == bufp)
- {
- nbdebug((" curbuf == bufp\n"));
- }
-
- if (bufno <= 0)
- return;
-
sprintf(buffer, "%d:killed=%d\n", bufno, r_cmdno);
nbdebug(("EVT: %s", buffer));
- nb_send(buffer, "netbeans_file_closed");
+ nb_send(buffer, "netbeans_file_killed");
if (nbbuf != NULL)
nbbuf->bufp = NULL;
Index: src/proto/netbeans.pro
===================================================================
--- src/proto/netbeans.pro (revision 1264)
+++ src/proto/netbeans.pro (working copy)
@@ -11,7 +11,7 @@
void netbeans_frame_moved __ARGS((int new_x, int new_y));
void netbeans_file_activated __ARGS((buf_T *bufp));
void netbeans_file_opened __ARGS((buf_T *bufp));
-void netbeans_file_closed __ARGS((buf_T *bufp));
+void netbeans_file_killed __ARGS((buf_T *bufp));
void netbeans_inserted __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, char_u *txt, int newlen));
void netbeans_removed __ARGS((buf_T *bufp, linenr_T linenr, colnr_T col, long len));
void netbeans_unmodified __ARGS((buf_T *bufp));
Index: src/buffer.c
===================================================================
--- src/buffer.c (revision 1264)
+++ src/buffer.c (working copy)
@@ -437,10 +437,6 @@
return;
#endif
-#ifdef FEAT_NETBEANS_INTG
- if (usingNetbeans)
- netbeans_file_closed(buf);
-#endif
/* Change directories when the 'acd' option is set. */
DO_AUTOCHDIR
@@ -639,6 +635,10 @@
#ifdef FEAT_SIGNS
buf_delete_signs(buf); /* delete any signs */
#endif
+#ifdef FEAT_NETBEANS_INTG
+ if (usingNetbeans)
+ netbeans_file_killed(buf);
+#endif
#ifdef FEAT_LOCALMAP
map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */
map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */
@@ -815,9 +815,6 @@
int bnr; /* buffer number */
char_u *p;
-#ifdef FEAT_NETBEANS_INTG
- netbeansCloseFile = 1;
-#endif
if (addr_count == 0)
{
(void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit);
@@ -912,9 +909,6 @@
}
}
-#ifdef FEAT_NETBEANS_INTG
- netbeansCloseFile = 0;
-#endif
return errormsg;
}
Index: src/globals.h
===================================================================
--- src/globals.h (revision 1264)
+++ src/globals.h (working copy)
@@ -1340,7 +1340,6 @@
#ifdef FEAT_NETBEANS_INTG
EXTERN char *netbeansArg INIT(= NULL); /* the -nb[:host:port:passwd] arg */
-EXTERN int netbeansCloseFile INIT(= 0); /* send killed if != 0 */
EXTERN int netbeansFireChanges INIT(= 1); /* send buffer changes if != 0 */
EXTERN int netbeansForcedQuit INIT(= 0);/* don't write modified files */
EXTERN int netbeansReadFile INIT(= 1); /* OK to read from disk if != 0 */