Skip to content

feat: use 'formatlistpat' length for breakindent#8594

Closed
habamax wants to merge 10 commits intovim:masterfrom
habamax:master
Closed

feat: use 'formatlistpat' length for breakindent#8594
habamax wants to merge 10 commits intovim:masterfrom
habamax:master

Conversation

@habamax
Copy link
Contributor

@habamax habamax commented Jul 20, 2021

Provided 'set briopt+=list:-1' use length of the matched 'formatlistpat' as additional indent to align contents of the list item.

@chrisbra pls check it, related to your PR #8564

PS, not sure how to write a proper test though.

Provided 'set briopt+=list:-1' use length of the matched 'formatlistpat'
as additional indent to align contents of the list item.
@chrisbra
Copy link
Member

looks quite good already. Will post some information on how to test later.

habamax added 3 commits July 20, 2021 11:39
Otherwise it looks like:

    * hello world
         next line has too much indent

Showbreak len is substracted after indent for the list is
calculated for proper alignment.
@habamax
Copy link
Contributor Author

habamax commented Jul 20, 2021

@chrisbra should I put "explicit brackets" there?

indent.c:956:9: error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=dangling-else]
      if (vim_regexec(&regmatch, line, 0))
         ^
cc1: all warnings being treated as errors
make: *** [objects/indent.o] Error 1
Makefile:3367: recipe for target 'objects/indent.o' failed
make: *** Waiting for unfinished jobs....
make: Leaving directory '/home/runner/work/vim/vim/src/shadow'
Error: Process completed with exit code 2.

It looks like your code I didn't change :)

@habamax
Copy link
Contributor Author

habamax commented Jul 20, 2021

And for macos build similar one for else:

indent.c:959:3: error: add explicit braces to avoid dangling else [-Werror,-Wdangling-else]
                else
                ^
1 error generated.

@chrisbra
Copy link
Member

	    if (vim_regexec(&regmatch, line, 0))
		if (wp->w_briopt_list > 0)
		    bri += wp->w_briopt_list;
		else
		    bri = (*regmatch.endp - *regmatch.startp);
	    vim_regfree(regmatch.regprog);
	}

please add braces after the top level if(vim_regex), the else is ambigious otherwise. So change that to:

	    if (vim_regexec(&regmatch, line, 0))
            {
		if (wp->w_briopt_list > 0)
		    bri += wp->w_briopt_list;
		else
		    bri = (*regmatch.endp - *regmatch.startp);
            }
	    vim_regfree(regmatch.regprog);
	}

@codecov
Copy link

codecov bot commented Jul 20, 2021

Codecov Report

Merging #8594 (209cd2f) into master (9bb0dad) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8594      +/-   ##
==========================================
- Coverage   90.05%   90.02%   -0.03%     
==========================================
  Files         150      150              
  Lines      168649   168450     -199     
==========================================
- Hits       151874   151646     -228     
- Misses      16775    16804      +29     
Flag Coverage Δ
huge-clang-none 89.19% <100.00%> (+0.12%) ⬆️
huge-gcc-none 89.55% <100.00%> (+0.02%) ⬆️
huge-gcc-testgui 88.17% <100.00%> (+<0.01%) ⬆️
huge-gcc-unittests 2.48% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/indent.c 93.84% <100.00%> (+0.01%) ⬆️
src/os_unix.c 71.25% <0.00%> (-1.49%) ⬇️
src/if_python.c 82.65% <0.00%> (-0.62%) ⬇️
src/gui.c 72.07% <0.00%> (-0.43%) ⬇️
src/term.c 83.28% <0.00%> (-0.43%) ⬇️
src/syntax.c 86.58% <0.00%> (-0.43%) ⬇️
src/ops.c 95.58% <0.00%> (-0.42%) ⬇️
src/getchar.c 91.14% <0.00%> (-0.39%) ⬇️
src/if_cscope.c 82.06% <0.00%> (-0.37%) ⬇️
src/ui.c 83.01% <0.00%> (-0.36%) ⬇️
... and 43 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9bb0dad...209cd2f. Read the comment docs.

@habamax
Copy link
Contributor Author

habamax commented Jul 20, 2021

@chrisbra I am not sure if multilevel list test is correct, could you check it pls?

habamax added 4 commits July 20, 2021 21:11
Now with local test run first.
With setl briopt+=list:-1 we get double list opts in the setting.
@habamax
Copy link
Contributor Author

habamax commented Jul 21, 2021

I think it is ready from my side, @chrisbra if you have any other suggestions, let me know, thank you!

@chrisbra
Copy link
Member

looks good, thanks

@brammool brammool closed this in f674b35 Jul 22, 2021
@habamax
Copy link
Contributor Author

habamax commented Jul 22, 2021

Thank you all!
image

janlazo added a commit to janlazo/neovim that referenced this pull request Aug 8, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 9, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 9, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 9, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
github-actions bot pushed a commit to dundargoc/neovim that referenced this pull request Aug 13, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
github-actions bot pushed a commit to dundargoc/neovim that referenced this pull request Aug 13, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
github-actions bot pushed a commit to dundargoc/neovim that referenced this pull request Aug 13, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
chrisbra pushed a commit to chrisbra/vim that referenced this pull request Aug 30, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim#8594)
muniter pushed a commit to muniter/neovim that referenced this pull request Sep 8, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
lewis6991 pushed a commit to lewis6991/neovim that referenced this pull request Dec 12, 2021
Problem:    Cannot use 'formatlistpat' for breakindent.
Solution:   Use a negative list indent. (Maxim Kim, closes vim/vim#8594)
vim/vim@f674b35

Port get_showbreak_value() from patch v8.1.2281
to avoid breaking changes when porting older patches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants