Re: [vim/vim] Multi-line Comment Indenting With C -- incorrect initial spacing (#8118)

2021-04-16 Fir de Conversatie Charles Campbell

cecamp (Vim Github Repository) wrote:


*Describe the bug*
Normally, a multi-line comment in C will show a new "*" at the correct 
indentation every time a carriage return is entered. However, that is 
not the case with the attached example file. Instead, extra (unwanted) 
spaces are prepended prior to the asterisk. Removing a line or two 
from the example file often shows no initial spacing.
(hopefully I've successfully attached cindent-prblm.c and bad.vimrc, 
because although nominally attached I don't see a confirmation list)


*To Reproduce*
Detailed steps to reproduce the behavior:

 1. vim -u bad.vimrc cindent-prblm.c
 2. Go to bottom of file: G
 3. Append to bottom of file: o
 4. You'll see that, instead of beginning with " * ", the line begins
with a number of unwanted extra spaces: " * "
 5. I will note that deleting a line in the comment area above
frequently changes the number of unwanted initial spaces,
sometimes yielding no initial spaces; ie. "* "

*Expected behavior*
It should start with " * " (or some number of spaces following the 
asterisk).

You can see what it should start with by

 1. vim -u bad.vimrc cindent-prblm.c
 2. Go to 4th line: 4G
 3. Append: o

*Environment (please complete the following information):*

  * Vim version [e.g. 8.1.1234] (Or paste the result of |vim --version|.)
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 16 2021 16:08:47)
Included patches: 1-2772
Compiled by c...@sphinx.fios-router.home

Huge version with GTK3 GUI. Features included (+) or not (-):
  * OS: [e.g. Ubuntu 18.04, Windows 10 1809, macOS 10.14]
Scientific Linux release 7.9 (Nitrogen)
  * Terminal: [e.g. GNOME Terminal, mintty, iTerm2, tmux, GNU screen]
(Use GUI if you use the GUI.)
gnome terminal 3.28.2


Well, that figures. Although I told the tracker to attach the two files, 
apparently it didn't. So I'll attach them now on the vimdev mailing 
list. Sorry about that...

Chip Campbell

--
--
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/9fa977ec-b92a-af50-c095-2f5bc412de42%40drchip.org.
/* e
 *  A
 *  D
 *  V
 *
 *  T
 *  w
 *  Q
 *  o
 *
 * -
 * E
 * -
 *
 *⌠
 *⎮
 *⌡
 *
 *  ₓ
 *  I
 *  ᶜ
 * t
 *   c
 * -
 * A
 * -
 *   α
 *   φ
 *   n
 *
 * -
 * Performance: {{{2
filetype indent on
set cino=>s,e0,n0,f0,{0,}4,^-1s,:0,=s,g0,h1s,p2,t0,+2,(2,)20,*30
set fo=nroql2


Patch 8.2.2772

2021-04-16 Fir de Conversatie Bram Moolenaar


Patch 8.2.2772
Problem:Problems when restoring 'runtimepath' from a session file.
Solution:   Add the "skiprtp" item in 'sessionoptions'.
Files:  runtime/doc/options.txt, src/session.c, src/optionstr.c,
src/option.h, src/vim.h, src/option.c,
src/testdir/test_mksession.vim


*** ../vim-8.2.2771/runtime/doc/options.txt 2021-03-29 20:49:01.482055371 
+0200
--- runtime/doc/options.txt 2021-04-16 19:33:33.503111856 +0200
***
*** 6507,6512 
--- 6511,6517 
global values for local options)
   options  all options and mappings (also global values for local
options)
+  skiprtp  exclude 'runtimepath' from the options
   resize   size of the Vim window: 'lines' and 'columns'
   sesdir   the directory in which the session file is located
will become the current directory (useful with
*** ../vim-8.2.2771/src/session.c   2021-03-13 13:52:29.813470884 +0100
--- src/session.c   2021-04-16 19:45:01.457421093 +0200
***
*** 1225,1232 
|| (eap->cmdidx == CMD_mksession
&& (*flagp & SSOP_OPTIONS)))
  #endif
failed |= (makemap(fd, NULL) == FAIL
!  || makeset(fd, OPT_GLOBAL, FALSE) == FAIL);
  
  #ifdef FEAT_SESSION
if (!failed && view_session)
--- 1225,1240 
|| (eap->cmdidx == CMD_mksession
&& (*flagp & SSOP_OPTIONS)))
  #endif
+   {
+   int flags = OPT_GLOBAL;
+ 
+ #ifdef FEAT_SESSION
+   if (eap->cmdidx == CMD_mksession && (*flagp & SSOP_SKIP_RTP))
+   flags |= OPT_SKIPRTP;
+ #endif
failed |= (makemap(fd, NULL) == FAIL
!|| makeset(fd, flags, FALSE) == FAIL);
!   }
  
  #ifdef FEAT_SESSION
if (!failed && view_session)
*** ../vim-8.2.2771/src/optionstr.c 2021-03-10 13:39:46.322350547 +0100
--- src/optionstr.c 2021-04-16 19:38:05.054600372 +0200
***
*** 34,43 
 "undo", "jump", NULL};
  #endif
  #ifdef FEAT_SESSION
! // Also used for 'viewoptions'!
  static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
  "localoptions", "options", "help", "blank", "globals", "slash", "unix",
! "sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", NULL};
  #endif
  // Keep in sync with SWB_ flags in option.h
  static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", 
"vsplit", "uselast", NULL};
--- 34,44 
 "undo", "jump", NULL};
  #endif
  #ifdef FEAT_SESSION
! // Also used for 'viewoptions'!  Keep in sync with SSOP_ flags.
  static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
  "localoptions", "options", "help", "blank", "globals", "slash", "unix",
! "sesdir", "curdir", "folds", "cursor", "tabpages", "terminal", "skiprtp",
! NULL};
  #endif
  // Keep in sync with SWB_ flags in option.h
  static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", 
"vsplit", "uselast", NULL};
*** ../vim-8.2.2771/src/option.h2021-03-29 20:49:01.486055361 +0200
--- src/option.h2021-04-16 19:44:10.669582326 +0200
***
*** 864,869 
--- 864,870 
  # define SSOP_CURSOR  0x4000
  # define SSOP_TABPAGES0x8000
  # define SSOP_TERMINAL0x1
+ # define SSOP_SKIP_RTP0x2
  #endif
  EXTERN char_u *p_sh;  // 'shell'
  EXTERN char_u *p_shcf;// 'shellcmdflag'
*** ../vim-8.2.2771/src/vim.h   2021-04-13 21:47:59.544306690 +0200
--- src/vim.h   2021-04-16 19:40:48.426274317 +0200
***
*** 1201,1206 
--- 1201,1207 
  #define OPT_NOWIN 0x20// don't set window-local options
  #define OPT_ONECOLUMN 0x40// list options one per line
  #define OPT_NO_REDRAW 0x80// ignore redraw flags on option
+ #define OPT_SKIPRTP   0x100   // "skiprtp" in 'sessionoptions'
  
  // Magic chars used in confirm dialog strings
  #define DLG_BUTTON_SEP'\n'
*** ../vim-8.2.2771/src/option.c2021-03-10 13:39:46.322350547 +0100
--- src/option.c2021-04-16 19:49:48.684575884 +0200
***
*** 4615,4620 
--- 4615,4623 
if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp))
continue;
  
+   if ((opt_flags & OPT_SKIPRTP) && p->var == (char_u *)_rtp)
+   continue;
+ 
round = 2;
if (p->indir != PV_NONE)
{
*** ../vim-8.2.2771/src/testdir/test_mksession.vim  2021-04-04 
15:28:55.509067733 +0200
--- src/testdir/test_mksession.vim  2021-04-16 19:57:06.895422586 +0200
***
*** 131,136 
--- 131,162 
set sessionoptions&
  endfunc
  
+ def Test_mksession_skiprtp()
+   mksession! Xtest_mks.out
+   var found = 0
+ 

Re: ReST Syntax

2021-04-16 Fir de Conversatie Marshall Ward
The issue is that indentation is preserved in standard text but not in 
comments, is that right?

I think that I agree this indentation in comments should be preserved.  
Christian's patch does not seem to be resolving the issue for me, but this 
did seem to get closer:

diff --git a/indent/rst.vim b/indent/rst.vim
index e1c7946..f3eb641 100644
--- a/indent/rst.vim
+++ b/indent/rst.vim
@@ -40,7 +40,7 @@ function GetRSTIndent()
   let psnum = s:get_paragraph_start()
   if psnum != 0
   if getline(psnum) =~ s:note_pattern
-  let ind = 3
+  let ind = max([3, ind])
   endif
   endif

That is, use the existing `ind` determined from the previous line.

I can submit this change after a bit of testing, assuming there's no 
obvious objections.


On Friday, 16 April 2021 at 06:11:24 UTC-4 cbl...@256bit.org wrote:

>
> On Mi, 14 Apr 2021, Friedrich Romstedt wrote:
>
> > Hi,
> > 
> > Am Fr., 7. Aug. 2020 um 15:18 Uhr schrieb Christian Brabandt
> > :
> > >
> > > I am not sure I understand the problem correctly. It sounds like you 
> are
> > > at one point just loading the syntax file, while when opening a proper
> > > rst file, Vim will also set the filetype (e.g. set some options and 
> also
> > > sets indenting options).
> > >
> > > Anyhow, it would actually help to see some specific examples of what
> > > works and what you expect. Please also have a look at the existing rst
> > > filetype as well as the indent plugin). Perhaps you can already disable
> > > any options that you do not like.
> > 
> > Yesterday I uploaded an asciinema cast regarding my issue:
> > https://asciinema.org/a/406969. It illustrates the behaviour I am
> > referring to by examples in-line.
>
> I looked into your last uploaded file. It looks like the behaviour is 
> hard coded in the indent script, so CC'ing the indent script maintainer.
>
> ,[ $VIMRUNTIME/indent/rst.vim ]-
> | function GetRSTIndent()
> | ...
> | let psnum = s:get_paragraph_start()
> | if psnum != 0
> | if getline(psnum) =~ s:note_pattern
> | let ind = 3
> | endif
> | endif
> `
>
> So it is hard coded to be three. I think a better approach would be the 
> following patch:
>
> diff --git a/runtime/indent/rst.vim b/runtime/indent/rst.vim
> index a31ad8e08..64db170d8 100644
> --- a/runtime/indent/rst.vim
> +++ b/runtime/indent/rst.vim
> @@ -38,9 +38,13 @@ function GetRSTIndent()
>
> let psnum = s:get_paragraph_start()
> if psnum != 0
> - if getline(psnum) =~ s:note_pattern
> - let ind = 3
> + if getline(psnum) =~ s:note_pattern
> + " return the indent after the first 2 leading '.'
> + let ind = match(getline(psnum), s:note_pattern .. '*\zs\S')
> + if ind < 3
> + let ind = 3
> endif
> + endif
> endif
>
> if line =~ s:itemization_pattern
>
> Best,
> Christian
> -- 
> Die Katholiken Terrorisieren das Land mit einer Auffassung vom Wesen
> der Ehe, die die ihre ist und die uns nichts angeht.
> -- Kurt Tucholsky
>

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/a2a0efc8-73cd-4a12-bf53-da7cc5769f30n%40googlegroups.com.


Re: ReST Syntax

2021-04-16 Fir de Conversatie Christian Brabandt


On Mi, 14 Apr 2021, Friedrich Romstedt wrote:

> Hi,
> 
> Am Fr., 7. Aug. 2020 um 15:18 Uhr schrieb Christian Brabandt
> :
> >
> > I am not sure I understand the problem correctly. It sounds like you are
> > at one point just loading the syntax file, while when opening a proper
> > rst file, Vim will also set the filetype (e.g. set some options and also
> > sets indenting options).
> >
> > Anyhow, it would actually help to see some specific examples of what
> > works and what you expect. Please also have a look at the existing rst
> > filetype as well as the indent plugin). Perhaps you can already disable
> > any options that you do not like.
> 
> Yesterday I uploaded an asciinema cast regarding my issue:
> https://asciinema.org/a/406969.  It illustrates the behaviour I am
> referring to by examples in-line.

I looked into your last uploaded file. It looks like the behaviour is 
hard coded in the indent script, so CC'ing the indent script maintainer.

,[ $VIMRUNTIME/indent/rst.vim ]-
| function GetRSTIndent()
|   ...
|   let psnum = s:get_paragraph_start()
|   if psnum != 0
|   if getline(psnum) =~ s:note_pattern
|   let ind = 3
|   endif
|   endif
`

So it is hard coded to be three. I think a better approach would be the 
following patch:

diff --git a/runtime/indent/rst.vim b/runtime/indent/rst.vim
index a31ad8e08..64db170d8 100644
--- a/runtime/indent/rst.vim
+++ b/runtime/indent/rst.vim
@@ -38,9 +38,13 @@ function GetRSTIndent()

   let psnum = s:get_paragraph_start()
   if psnum != 0
-  if getline(psnum) =~ s:note_pattern
-  let ind = 3
+if getline(psnum) =~ s:note_pattern
+  " return the indent after the first 2 leading '.'
+  let ind = match(getline(psnum), s:note_pattern .. '*\zs\S')
+  if ind < 3
+let ind = 3
   endif
+endif
   endif

   if line =~ s:itemization_pattern

Best,
Christian
-- 
Die Katholiken Terrorisieren das Land mit einer Auffassung vom Wesen
der Ehe, die die ihre ist und die uns nichts angeht.
-- Kurt Tucholsky

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20210416101112.GI154%40256bit.org.


Re: ReST Syntax

2021-04-16 Fir de Conversatie Friedrich Romstedt
Hi,

Am Fr., 7. Aug. 2020 um 15:18 Uhr schrieb Christian Brabandt
:
>
> I am not sure I understand the problem correctly. It sounds like you are
> at one point just loading the syntax file, while when opening a proper
> rst file, Vim will also set the filetype (e.g. set some options and also
> sets indenting options).
>
> Anyhow, it would actually help to see some specific examples of what
> works and what you expect. Please also have a look at the existing rst
> filetype as well as the indent plugin). Perhaps you can already disable
> any options that you do not like.

Yesterday I uploaded an asciinema cast regarding my issue:
https://asciinema.org/a/406969.  It illustrates the behaviour I am
referring to by examples in-line.

Best,
Friedrich

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAN06%3DCw2dq0aNZ5uEwsVytOe5z%3Dz%2BqzYs%3DoUAWS_wRNDfB%2BPgQ%40mail.gmail.com.