To: vim-dev@vim.org Subject: Patch 6.2.215 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.215 Problem: NetBeans: problems saving an unmodified file. Solution: Add isNetbeansModified() function. Disable netbeans_unmodified(). (Gordon Prieur) Files: src/fileio.c, src/netbeans.c, src/proto/netbeans.pro, runtime/doc/netbeans.txt, runtime/doc/tags *** ../vim-6.2.214/src/fileio.c Sun Jan 25 20:45:55 2004 --- src/fileio.c Fri Jan 30 20:15:37 2004 *************** *** 2663,2669 **** { if (whole) { ! if (buf->b_changed) { netbeans_save_buffer(buf); return retval; --- 2663,2673 ---- { if (whole) { ! /* ! * b_changed can be 0 after an undo, but we still need to write ! * the buffer to NetBeans. ! */ ! if (buf->b_changed || isNetbeansModified(buf)) { netbeans_save_buffer(buf); return retval; *** ../vim-6.2.214/src/netbeans.c Sun Jan 25 19:40:26 2004 --- src/netbeans.c Fri Jan 30 20:45:18 2004 *************** *** 785,790 **** --- 785,810 ---- } /* + * NetBeans and Vim have different undo models. In Vim, the file isn't + * changed if changes are undone via the undo command. In NetBeans, once + * a change has been made the file is marked as modified until saved. It + * doesn't matter if the change was undone. + * + * So this function is for the corner case where Vim thinks a buffer is + * unmodified but NetBeans thinks it IS modified. + */ + int + isNetbeansModified(buf_T *bufp) + { + int bufno = nb_getbufno(bufp); + + if (bufno > 0) + return buf_list[bufno].modified; + else + return FALSE; + } + + /* * Given a Netbeans buffer number, return the netbeans buffer. * Returns NULL for 0 or a negative number. A 0 bufno means a * non-buffer related command has been sent. *************** *** 1496,1501 **** --- 1516,1524 ---- return FAIL; } buf->fireChanges = 0; + if (buf->bufp != NULL && !buf->bufp->b_netbeans_file) + EMSGN(_("E658: NetBeans connection lost for buffer %ld"), + buf->bufp->b_fnum); /* =====================================================================*/ } else if (streq((char *)cmd, "setTitle")) *************** *** 2504,2516 **** --- 2527,2543 ---- /* * Send netbeans an unmodufied command. */ + /*ARGSUSED*/ void netbeans_unmodified(buf_T *bufp) { + #if 0 char_u buf[128]; int bufno; nbbuf_T *nbbuf; + /* This has been disabled, because NetBeans considers a buffer modified + * even when all changes have been undone. */ nbbuf = nb_bufp2nbbuf_fire(bufp, &bufno); if (nbbuf == NULL) return; *************** *** 2520,2525 **** --- 2547,2553 ---- sprintf((char *)buf, "%d:unmodified=%d\n", bufno, cmdno); nbdebug(("EVT: %s", buf)); nb_send((char *)buf, "netbeans_unmodified"); + #endif } /* *** ../vim-6.2.214/src/proto/netbeans.pro Sun Jan 18 21:31:56 2004 --- src/proto/netbeans.pro Fri Jan 30 20:15:58 2004 *************** *** 4,9 **** --- 4,10 ---- void netbeans_w32_connect __ARGS((void)); void messageFromNetbeansW32 __ARGS((void)); int isNetbeansBuffer __ARGS((buf_T *bufp)); + int isNetbeansModified __ARGS((buf_T *bufp)); void netbeans_end __ARGS((void)); void netbeans_startup_done __ARGS((void)); void netbeans_frame_moved __ARGS((int new_x, int new_y)); *** ../vim-6.2.214/runtime/doc/netbeans.txt Sun Jan 18 21:31:56 2004 --- runtime/doc/netbeans.txt Fri Jan 30 20:16:10 2004 *************** *** 189,194 **** --- 189,202 ---- NetBeans does not support partial writes for buffers that were opened from NetBeans. + *E658* + NetBeans connection lost for this buffer + NetBeans has become confused about the state of this file. + Rather than risc data corruption, NetBeans has severed the + connection for this file. Vim will take over responsibility + for saving changes to this file and NetBeans will no longer + know of these changes. + ============================================================================== 9. Running Vim from NetBeans *netbeans-run* *** ../vim-6.2.214/runtime/doc/tags Sun Jan 18 21:19:56 2004 --- runtime/doc/tags Fri Jan 30 20:40:22 2004 *************** *** 3420,3425 **** --- 3454,3463 ---- E652 netbeans.txt /*E652* E653 netbeans.txt /*E653* E654 netbeans.txt /*E654* + E655 eval.txt /*E655* + E656 netbeans.txt /*E656* + E657 netbeans.txt /*E657* + E658 netbeans.txt /*E658* E66 syntax.txt /*E66* E67 syntax.txt /*E67* E68 pattern.txt /*E68* *** ../vim-6.2.214/src/version.c Wed Jan 1 01:32:06 2003 --- src/version.c Fri Jan 30 21:00:52 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 215, /**/ -- I learned the customs and mannerisms of engineers by observing them, much the way Jane Goodall learned about the great apes, but without the hassle of grooming. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///