Hi William!
On Mi, 11 Dez 2013, William Gardner wrote:
> I've got an autocommand that triggers on TextChanged and does some
> processing (removing trailing whitespace) on the just-modified lines,
> which it finds via the '[ and '] marks.
>
> The problem is, J (join lines) doesn't update those marks. In fact,
> they're not even updated to account for the fact that a line was just
> removed from the buffer. If they used to point to lines 77 and 78,
> they still point to lines 77 and 78 even if I just removed line 60 by
> joining it to line 59 (letter marks are updated, so they still point
> to the same text). This leads to errors in some cases, and operating
> on lines I didn't intend to in others.
>
> Somewhat comically, undoing a join does update the '[ '] marks (so
> they point to the un-joined lines).
>
> Sounds like a bug to me. Or is this actually intended?
It was probably forgotten and no one has ever noticed :(
Attached is a patch.
Best,
Christian
--
Glauben und Wissen verhalten sich wie zwei Schalen einer Waage: in dem
Maße, als die eine steigt, sinkt die andere.
-- Arthur Schopenhauer
--
--
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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -4452,6 +4452,11 @@
for (t = 0; t < count; ++t)
{
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
+ if (!t)
+ {
+ curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
+ curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr);
+ }
#if defined(FEAT_COMMENTS) || defined(PROTO)
if (remove_comments)
{
@@ -4568,6 +4573,9 @@
}
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
+ curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum;
+ curwin->w_buffer->b_op_end.col = (colnr_T)STRLEN(newp);
+
/* Only report the change in the first line here, del_lines() will report
* the deleted line. */
changed_lines(curwin->w_cursor.lnum, currsize,