Patch 9.0.0133
Problem: Virtual text after line moves to joined line. (Yegappan
Lakshmanan)
Solution: When joining lines only keep virtual text after the last line.
Files: src/textprop.c, src/proto/textprop.pro, src/ops.c,
src/testdir/test_textprop.vim,
src/testdir/dumps/Test_prop_with_text_after_joined_1.dump
*** ../vim-9.0.0132/src/textprop.c 2022-08-01 16:11:02.656646804 +0100
--- src/textprop.c 2022-08-01 22:03:07.426795153 +0100
***************
*** 600,606 ****
* be considered.
*/
int
! count_props(linenr_T lnum, int only_starting)
{
char_u *props;
int proplen = get_text_props(curbuf, lnum, &props, 0);
--- 600,606 ----
* be considered.
*/
int
! count_props(linenr_T lnum, int only_starting, int last_line)
{
char_u *props;
int proplen = get_text_props(curbuf, lnum, &props, 0);
***************
*** 608,620 ****
int i;
textprop_T prop;
! if (only_starting)
! for (i = 0; i < proplen; ++i)
! {
! mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
! if (prop.tp_flags & TP_FLAG_CONT_PREV)
! --result;
! }
return result;
}
--- 608,623 ----
int i;
textprop_T prop;
! for (i = 0; i < proplen; ++i)
! {
! mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
! // A prop is droppend when in the first line and it continues from the
! // previous line, or when not in the last line and it is virtual text
! // after the line.
! if ((only_starting && (prop.tp_flags & TP_FLAG_CONT_PREV))
! || (!last_line && prop.tp_col == MAXCOL))
! --result;
! }
return result;
}
***************
*** 2024,2030 ****
int propcount,
int *props_remaining,
linenr_T lnum,
! int add_all,
long col,
int removed)
{
--- 2027,2033 ----
int propcount,
int *props_remaining,
linenr_T lnum,
! int last_line,
long col,
int removed)
{
***************
*** 2038,2049 ****
int end;
mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
end = !(prop.tp_flags & TP_FLAG_CONT_NEXT);
adjust_prop(&prop, 0, -removed, 0); // Remove leading spaces
adjust_prop(&prop, -1, col, 0); // Make line start at its final column
! if (add_all || end)
mch_memmove(new_props + --(*props_remaining) * sizeof(prop),
&prop, sizeof(prop));
else
--- 2041,2054 ----
int end;
mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
+ if (prop.tp_col == MAXCOL && !last_line)
+ continue; // drop property with text after the line
end = !(prop.tp_flags & TP_FLAG_CONT_NEXT);
adjust_prop(&prop, 0, -removed, 0); // Remove leading spaces
adjust_prop(&prop, -1, col, 0); // Make line start at its final column
! if (last_line || end)
mch_memmove(new_props + --(*props_remaining) * sizeof(prop),
&prop, sizeof(prop));
else
*** ../vim-9.0.0132/src/proto/textprop.pro 2022-07-25 18:13:33.050580738
+0100
--- src/proto/textprop.pro 2022-08-01 22:03:19.086791605 +0100
***************
*** 4,10 ****
void f_prop_add_list(typval_T *argvars, typval_T *rettv);
int prop_add_common(linenr_T start_lnum, colnr_T start_col, dict_T *dict,
buf_T *default_buf, typval_T *dict_arg);
int get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int
will_change);
! int count_props(linenr_T lnum, int only_starting);
int find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop,
linenr_T *found_lnum);
proptype_T *text_prop_type_by_id(buf_T *buf, int id);
void f_prop_clear(typval_T *argvars, typval_T *rettv);
--- 4,10 ----
void f_prop_add_list(typval_T *argvars, typval_T *rettv);
int prop_add_common(linenr_T start_lnum, colnr_T start_col, dict_T *dict,
buf_T *default_buf, typval_T *dict_arg);
int get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int
will_change);
! int count_props(linenr_T lnum, int only_starting, int last_line);
int find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop,
linenr_T *found_lnum);
proptype_T *text_prop_type_by_id(buf_T *buf, int id);
void f_prop_clear(typval_T *argvars, typval_T *rettv);
***************
*** 20,24 ****
void clear_buf_prop_types(buf_T *buf);
int adjust_prop_columns(linenr_T lnum, colnr_T col, int bytes_added, int
flags);
void adjust_props_for_split(linenr_T lnum_props, linenr_T lnum_top, int kept,
int deleted);
! void prepend_joined_props(char_u *new_props, int propcount, int
*props_remaining, linenr_T lnum, int add_all, long col, int removed);
/* vim: set ft=c : */
--- 20,24 ----
void clear_buf_prop_types(buf_T *buf);
int adjust_prop_columns(linenr_T lnum, colnr_T col, int bytes_added, int
flags);
void adjust_props_for_split(linenr_T lnum_props, linenr_T lnum_top, int kept,
int deleted);
! void prepend_joined_props(char_u *new_props, int propcount, int
*props_remaining, linenr_T lnum, int last_line, long col, int removed);
/* vim: set ft=c : */
*** ../vim-9.0.0132/src/ops.c 2022-07-30 16:54:01.867698285 +0100
--- src/ops.c 2022-08-01 22:09:37.058648407 +0100
***************
*** 2012,2018 ****
{
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
#ifdef FEAT_PROP_POPUP
! propcount += count_props((linenr_T) (curwin->w_cursor.lnum + t), t > 0);
#endif
if (t == 0 && setmark && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)
{
--- 2012,2019 ----
{
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
#ifdef FEAT_PROP_POPUP
! propcount += count_props((linenr_T) (curwin->w_cursor.lnum + t),
! t > 0, t + 1 == count);
#endif
if (t == 0 && setmark && (cmdmod.cmod_flags & CMOD_LOCKMARKS) == 0)
{
***************
*** 2147,2153 ****
curwin->w_cursor.lnum + t, t == count - 1,
(long)(cend - newp), spaces_removed);
#endif
-
if (t == 0)
break;
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1));
--- 2148,2153 ----
*** ../vim-9.0.0132/src/testdir/test_textprop.vim 2022-08-01
16:50:58.869575285 +0100
--- src/testdir/test_textprop.vim 2022-08-01 22:12:58.186556839 +0100
***************
*** 2243,2248 ****
--- 2243,2274 ----
call delete('XscriptPropsWithTextAfter')
endfunc
+ func Test_props_with_text_after_joined()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ call setline(1, ['one', 'two', 'three', 'four'])
+ call prop_type_add('afterprop', #{highlight: 'Search'})
+ call prop_add(1, 0, #{type: 'afterprop', text: ' ONE', text_align:
'after'})
+ call prop_add(4, 0, #{type: 'afterprop', text: ' FOUR', text_align:
'after'})
+ normal ggJ
+ normal GkJ
+
+ call setline(3, ['a', 'b', 'c', 'd', 'e', 'f'])
+ call prop_add(3, 0, #{type: 'afterprop', text: ' AAA', text_align:
'after'})
+ call prop_add(5, 0, #{type: 'afterprop', text: ' CCC', text_align:
'after'})
+ call prop_add(7, 0, #{type: 'afterprop', text: ' EEE', text_align:
'after'})
+ call prop_add(8, 0, #{type: 'afterprop', text: ' FFF', text_align:
'after'})
+ normal 3G6J
+ END
+ call writefile(lines, 'XscriptPropsWithTextAfterJoined')
+ let buf = RunVimInTerminal('-S XscriptPropsWithTextAfterJoined', #{rows: 6,
cols: 60})
+ call VerifyScreenDump(buf, 'Test_prop_with_text_after_joined_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XscriptPropsWithTextAfterJoined')
+ endfunc
+
func Test_removed_prop_with_text_cleans_up_array()
new
call setline(1, 'some text here')
*** ../vim-9.0.0132/src/testdir/dumps/Test_prop_with_text_after_joined_1.dump
2022-08-01 22:16:59.600536521 +0100
--- src/testdir/dumps/Test_prop_with_text_after_joined_1.dump 2022-08-01
22:13:23.762544691 +0100
***************
*** 0 ****
--- 1,6 ----
+ |o+0&#ffffff0|n|e| |t|w|o| @52
+ |t|h|r|e@1| |f|o|u|r| +0&#ffff4012|F|O|U|R| +0&#ffffff0@44
+ |a| |b| |c| |d| |e> |f| +0&#ffff4012|F@2| +0&#ffffff0@44
+ |~+0#4040ff13&| @58
+ |~| @58
+ | +0#0000000&@41|3|,|1|0| @9|A|l@1|
*** ../vim-9.0.0132/src/version.c 2022-08-01 16:50:58.869575285 +0100
--- src/version.c 2022-08-01 21:35:55.593941508 +0100
***************
*** 737,738 ****
--- 737,740 ----
{ /* Add new patch number below this line */
+ /**/
+ 133,
/**/
--
If evolution theories are correct, humans will soon grow a third
hand for operating the mouse.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220801211922.D53E81C0656%40moolenaar.net.