Patch 9.0.0214
Problem:    Splitting a line may duplicate virtual text. (Ben Jackson)
Solution:   Don't duplicate a text property with virtual text. Make
            auto-indenting work better. (closes #10919)
Files:      src/textprop.c, src/vim.h, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_insert_start_incl_1.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_2.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_3.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_4.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_5.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_6.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_7.dump,
            src/testdir/dumps/Test_prop_insert_start_incl_8.dump


*** ../vim-9.0.0213/src/textprop.c      2022-08-14 14:16:08.003582142 +0100
--- src/textprop.c      2022-08-15 15:17:59.131909539 +0100
***************
*** 1906,1911 ****
--- 1906,1912 ----
   * Only for the current buffer.
   * "flags" can have:
   * APC_SUBSTITUTE:    Text is replaced, not inserted.
+  * APC_INDENT:                Text is inserted before virtual text prop
   */
      static adjustres_T
  adjust_prop(
***************
*** 1931,1936 ****
--- 1932,1941 ----
      start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL))
                                || (flags & APC_SUBSTITUTE)
                                || (prop->tp_flags & TP_FLAG_CONT_PREV);
+     if (prop->tp_id < 0 && (flags & APC_INDENT))
+       // when inserting indent just before a character with virtual text
+       // shift the text property
+       start_incl = FALSE;
      end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL))
                                || (prop->tp_flags & TP_FLAG_CONT_NEXT);
      // do not drop zero-width props if they later can increase in size
***************
*** 1982,1987 ****
--- 1987,1993 ----
   * "flags" can have:
   * APC_SAVE_FOR_UNDO: Call u_savesub() before making changes to the line.
   * APC_SUBSTITUTE:    Text is replaced, not inserted.
+  * APC_INDENT:                Text is inserted before virtual text prop
   * Caller is expected to check b_has_textprop and "bytes_added" being 
non-zero.
   * Returns TRUE when props were changed.
   */
***************
*** 2097,2102 ****
--- 2103,2111 ----
        cont_prev = prop.tp_col != MAXCOL && prop.tp_col + !start_incl <= kept;
        cont_next = prop.tp_col != MAXCOL
                           && skipped <= prop.tp_col + prop.tp_len - !end_incl;
+       // when a prop has text it is never copied
+       if (prop.tp_id < 0 && cont_next)
+           cont_prev = FALSE;
  
        if (cont_prev && ga_grow(&prevprop, 1) == OK)
        {
*** ../vim-9.0.0213/src/vim.h   2022-08-14 14:16:08.003582142 +0100
--- src/vim.h   2022-08-15 15:12:48.555760757 +0100
***************
*** 2778,2783 ****
--- 2778,2784 ----
  // Flags for adjust_prop_columns()
  #define APC_SAVE_FOR_UNDO     1   // call u_savesub() before making changes
  #define APC_SUBSTITUTE                2   // text is replaced, not inserted
+ #define APC_INDENT            4   // changing indent
  
  #define CLIP_ZINDEX 32000
  
*** ../vim-9.0.0213/src/testdir/test_textprop.vim       2022-08-14 
19:36:51.503751154 +0100
--- src/testdir/test_textprop.vim       2022-08-15 15:40:39.264191722 +0100
***************
*** 2943,2955 ****
  
    let lines =<< trim END
        vim9script
!       setline(1, 'text one text two')
  
        prop_type_add('propincl', {highlight: 'NonText', start_incl: true})
        prop_add(1, 6, {type: 'propincl', text: 'after '})
        cursor(1, 6)
        prop_type_add('propnotincl', {highlight: 'NonText', start_incl: false})
        prop_add(1, 15, {type: 'propnotincl', text: 'before '})
    END
    call writefile(lines, 'XscriptPropsStartIncl')
    let buf = RunVimInTerminal('-S XscriptPropsStartIncl', #{rows: 8, cols: 60})
--- 2943,2959 ----
  
    let lines =<< trim END
        vim9script
!       setline(1, ['text one text two', '', 'function(arg)'])
  
        prop_type_add('propincl', {highlight: 'NonText', start_incl: true})
        prop_add(1, 6, {type: 'propincl', text: 'after '})
        cursor(1, 6)
        prop_type_add('propnotincl', {highlight: 'NonText', start_incl: false})
        prop_add(1, 15, {type: 'propnotincl', text: 'before '})
+ 
+       set cindent sw=4 
+       prop_type_add('argname', {highlight: 'DiffChange', start_incl: true})
+       prop_add(3, 10, {type: 'argname', text: 'arg: '})
    END
    call writefile(lines, 'XscriptPropsStartIncl')
    let buf = RunVimInTerminal('-S XscriptPropsStartIncl', #{rows: 8, cols: 60})
***************
*** 2965,2970 ****
--- 2969,2981 ----
    call term_sendkeys(buf, "yy\<Esc>")
    call VerifyScreenDump(buf, 'Test_prop_insert_start_incl_5', {})
  
+   call term_sendkeys(buf, "3Gfai\<CR>\<Esc>")
+   call VerifyScreenDump(buf, 'Test_prop_insert_start_incl_6', {})
+   call term_sendkeys(buf, ">>")
+   call VerifyScreenDump(buf, 'Test_prop_insert_start_incl_7', {})
+   call term_sendkeys(buf, "<<<<")
+   call VerifyScreenDump(buf, 'Test_prop_insert_start_incl_8', {})
+ 
    call StopVimInTerminal(buf)
    call delete('XscriptPropsStartIncl')
  endfunc
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_1.dump        
2022-08-14 13:28:36.223224725 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_1.dump        2022-08-15 
15:26:37.676019510 +0100
***************
*** 1,8 ****
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| >o+0#0000000&|n|e| |t|e|x|t| 
|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @29
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
- |~| @58
- |~| @58
  | +0#0000000&@41|1|,|6|-|1|2| @7|A|l@1| 
--- 1,8 ----
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| >o+0#0000000&|n|e| |t|e|x|t| 
|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @29
+ @60
+ |f|u|n|c|t|i|o|n|(|a+0&#ffd7ff255|r|g|:| |a+0&#ffffff0|r|g|)| @41
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
  | +0#0000000&@41|1|,|6|-|1|2| @7|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_2.dump        
2022-08-14 13:28:36.223224725 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_2.dump        2022-08-15 
15:26:39.532008827 +0100
***************
*** 1,8 ****
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| >o+0#0000000&|n|e| |t|e|x|t| 
|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @29
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
- |~| @58
- |~| @58
  |-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|6|-|1|2| @7|A|l@1| 
--- 1,8 ----
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| >o+0#0000000&|n|e| |t|e|x|t| 
|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @29
+ @60
+ |f|u|n|c|t|i|o|n|(|a+0&#ffd7ff255|r|g|:| |a+0&#ffffff0|r|g|)| @41
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
  |-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|6|-|1|2| @7|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_3.dump        
2022-08-14 13:28:36.223224725 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_3.dump        2022-08-15 
15:26:41.383998182 +0100
***************
*** 1,8 ****
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&>x|o|n|e| |t|e|x|t| 
|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @27
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
- |~| @58
- |~| @58
  | +0#0000000&@41|1|,|7|-|1|3| @7|A|l@1| 
--- 1,8 ----
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&>x|o|n|e| |t|e|x|t| 
|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @27
+ @60
+ |f|u|n|c|t|i|o|n|(|a+0&#ffd7ff255|r|g|:| |a+0&#ffffff0|r|g|)| @41
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
  | +0#0000000&@41|1|,|7|-|1|3| @7|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_4.dump        
2022-08-14 13:28:36.223224725 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_4.dump        2022-08-15 
15:26:43.263987393 +0100
***************
*** 1,8 ****
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
>b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @27
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
- |~| @58
- |~| @58
  |-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|1|7|-|2|3| @6|A|l@1| 
--- 1,8 ----
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
>b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @27
+ @60
+ |f|u|n|c|t|i|o|n|(|a+0&#ffd7ff255|r|g|:| |a+0&#ffffff0|r|g|)| @41
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
  |-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|1|7|-|2|3| @6|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_5.dump        
2022-08-14 13:28:36.223224725 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_5.dump        2022-08-15 
15:37:30.972932903 +0100
***************
*** 1,8 ****
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
|y>y|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @25
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
- |~| @58
- |~| @58
  | +0#0000000&@41|1|,|1|8|-|2|4| @6|A|l@1| 
--- 1,8 ----
  |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
|y>y|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @25
+ @60
+ |f|u|n|c|t|i|o|n|(|a+0&#ffd7ff255|r|g|:| |a+0&#ffffff0|r|g|)| @41
  |~+0#4040ff13&| @58
  |~| @58
  |~| @58
  |~| @58
  | +0#0000000&@41|1|,|1|8|-|2|4| @6|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_6.dump        
2022-08-15 15:41:52.767911748 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_6.dump        2022-08-15 
15:37:32.028928633 +0100
***************
*** 0 ****
--- 1,8 ----
+ |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
|y@1|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @25
+ @60
+ |f|u|n|c|t|i|o|n|(| @50
+ @7> |a+0&#ffd7ff255|r|g|:| |a+0&#ffffff0|r|g|)| @42
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@41|4|,|1|-|8| @8|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_7.dump        
2022-08-15 15:41:52.771911734 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_7.dump        2022-08-15 
15:37:33.180923975 +0100
***************
*** 0 ****
--- 1,8 ----
+ |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
|y@1|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @25
+ @60
+ |f|u|n|c|t|i|o|n|(| @50
+ @12|a+0&#ffd7ff255|r|g|:| >a+0&#ffffff0|r|g|)| @38
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@41|4|,|6|-|1|8| @7|A|l@1| 
*** ../vim-9.0.0213/src/testdir/dumps/Test_prop_insert_start_incl_8.dump        
2022-08-15 15:41:52.775911718 +0100
--- src/testdir/dumps/Test_prop_insert_start_incl_8.dump        2022-08-15 
15:40:43.000177380 +0100
***************
*** 0 ****
--- 1,8 ----
+ |t+0&#ffffff0|e|x|t| |a+0#4040ff13&|f|t|e|r| |x+0#0000000&@1|o|n|e| |t|e|x|t| 
|y@1|b+0#4040ff13&|e|f|o|r|e| |t+0#0000000&|w|o| @25
+ @60
+ |f|u|n|c|t|i|o|n|(| @50
+ @4|a+0&#ffd7ff255|r|g|:| >a+0&#ffffff0|r|g|)| @46
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@41|4|,|5|-|1|0| @7|A|l@1| 
*** ../vim-9.0.0213/src/version.c       2022-08-14 22:22:59.230654518 +0100
--- src/version.c       2022-08-15 15:20:16.634654114 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     214,
  /**/

-- 
GUARD #1:  What -- a swallow carrying a coconut?
ARTHUR:    It could grip it by the husk!
GUARD #1:  It's not a question of where he grips it!  It's a simple question
           of weight ratios!  A five ounce bird could not carry a 1 pound
           coconut.
                                  The Quest for the Holy Grail (Monty Python)

 /// 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/20220815145646.8D8081C1094%40moolenaar.net.

Raspunde prin e-mail lui