As described in [1], the netbeans protocol "insert" command is behaving incorrectly when the offset is in the middle of the line. After some source diving, I discovered that the code was appending "for simplicity." This patch fixes the command to insert instead.

This is my first vim patch. I tried to follow the suggestions in develop.txt. Notably, however, I'm uncertain if a function already exists to insert text in a line. If there is, it might be better to use it than to do the memmove and STRCAT calls I'm doing.

[1] http://permalink.gmane.org/gmane.editors.vim.devel/34102

--
Brian

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 161d01cbb165 src/netbeans.c
--- a/src/netbeans.c    Fri Apr 13 23:04:47 2012 +0200
+++ b/src/netbeans.c    Mon Apr 16 12:28:18 2012 -0400
@@ -1812,14 +1812,14 @@
                        char_u *oldline = ml_get(lnum);
                        char_u *newline;
 
-                       /* Insert halfway a line.  For simplicity we assume we
-                        * need to append to the line. */
                        newline = alloc_check(
                                       (unsigned)(STRLEN(oldline) + len + 1));
                        if (newline != NULL)
                        {
-                           STRCPY(newline, oldline);
+                           mch_memmove(newline, oldline, pos->col);
+                           newline[pos->col] = '\0';
                            STRCAT(newline, args);
+                           STRCAT(newline, oldline + pos->col);
                            ml_replace(lnum, newline, FALSE);
                        }
                    }

Raspunde prin e-mail lui