[patch] remove dead-code in textprop.c

23 views
Skip to first unread message

Christian Brabandt

unread,
Oct 25, 2019, 5:22:32 AM10/25/19
to vim...@vim.org
Bram,
while looking into #4427 I noticed that there is some dead code, that
cannot be reached. So here is a patch:

diff --git a/src/textprop.c b/src/textprop.c
index cc95546e2..7029daaae 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1067,13 +1067,7 @@ adjust_prop_columns(
if (bytes_added > 0
&& (tmp_prop.tp_col >= col + (start_incl ? 2 : 1)))
{
- if (tmp_prop.tp_col < col + (start_incl ? 2 : 1))
- {
- tmp_prop.tp_len += (tmp_prop.tp_col - 1 - col) + bytes_added;
- tmp_prop.tp_col = col + 1;
- }
- else
- tmp_prop.tp_col += bytes_added;
+ tmp_prop.tp_col += bytes_added;
// Save for undo if requested and not done yet.
if ((flags & APC_SAVE_FOR_UNDO) && !dirty)
u_savesub(lnum);


BTW: I think the problem for #4427 is, that one uses the old byte column
numbers for adjust_prop_columns(), while one should use the column
numbers for the newly added text.


Mit freundlichen Grüßen
Christian
--
Da hilft kein Zorn. Da hilft kein Spott.
Da hilft kein Weinen, hilft kein Beten.
Die Nachricht stimmt! Der Liebe Gott
ist aus der Kirche ausgetreten.
-- Erich Kästner

Christian Brabandt

unread,
Oct 25, 2019, 10:26:57 AM10/25/19
to vim...@vim.org
I think the attached patch fixes the problem.

I don't know text properties very well, so please verify.

Best,
Christian
--
Gescheit - gescheiter - gescheitert.
0001-Adjust-text-property-correctly-for-s.patch

Bram Moolenaar

unread,
Oct 25, 2019, 3:52:40 PM10/25/19
to vim...@googlegroups.com, Christian Brabandt, vim...@vim.org

Christian wrote:

> while looking into #4427 I noticed that there is some dead code, that
> cannot be reached. So here is a patch:
>
> diff --git a/src/textprop.c b/src/textprop.c
> index cc95546e2..7029daaae 100644
> --- a/src/textprop.c
> +++ b/src/textprop.c
> @@ -1067,13 +1067,7 @@ adjust_prop_columns(
> if (bytes_added > 0
> && (tmp_prop.tp_col >= col + (start_incl ? 2 : 1)))
> {
> - if (tmp_prop.tp_col < col + (start_incl ? 2 : 1))
> - {
> - tmp_prop.tp_len += (tmp_prop.tp_col - 1 - col) + bytes_added;
> - tmp_prop.tp_col = col + 1;
> - }
> - else
> - tmp_prop.tp_col += bytes_added;
> + tmp_prop.tp_col += bytes_added;
> // Save for undo if requested and not done yet.
> if ((flags & APC_SAVE_FOR_UNDO) && !dirty)
> u_savesub(lnum);

I'll include it, thanks. Although I wonder if another situation needs
to be handled.

> BTW: I think the problem for #4427 is, that one uses the old byte column
> numbers for adjust_prop_columns(), while one should use the column
> numbers for the newly added text.

I had completely missed that issue. Added to the todo list now.
But perhaps you are already making a fix?

--
For large projects, Team Leaders use sophisticated project management software
to keep track of who's doing what. The software collects the lies and guesses
of the project team and organizes them in to instantly outdated charts that
are too boring to look at closely. This is called "planning".
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
Oct 25, 2019, 4:38:11 PM10/25/19
to vim...@googlegroups.com, Christian Brabandt, vim...@vim.org
The computation wasn't quite right, but it was in the right place. We
need to accumulate the added bytes.

--
You can test a person's importance in the organization by asking how much RAM
his computer has. Anybody who knows the answer to that question is not a
decision-maker.
Reply all
Reply to author
Forward
0 new messages