annotate runtime/indent/rst.vim @ 34548:db67c09ccd53 v9.1.0175

patch 9.1.0175: wrong window positions with 'winfix{width,height}' Commit: https://github.com/vim/vim/commit/5866bc3a0f54115d5982fdc09bdbe4c45069265a Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Wed Mar 13 20:17:24 2024 +0100 patch 9.1.0175: wrong window positions with 'winfix{width,height}' Problem: winframe functions incorrectly recompute window positions if the altframe wasn't adjacent to the closed frame, which is possible if adjacent windows had 'winfix{width,height}' set. Solution: recompute for windows within the parent of the altframe and closed frame. Skip this (as before) if the altframe was top/left, but only if adjacent to the closed frame, as positions won't change in that case. Also correct the return value documentation for win_screenpos. (Sean Dewar) The issue revealed itself after removing the win_comp_pos call below winframe_restore in win_splitmove. Similarly, wrong positions could result from windows closed in other tabpages, as win_free_mem uses winframe_remove (at least until it is entered later, where enter_tabpage calls win_comp_pos). NOTE: As win_comp_pos handles only curtab, it's possible via other means for positions in non-current tabpages to be wrong (e.g: after changing 'laststatus', 'showtabline', etc.). Given enter_tabpage recomputes it, maybe it's intentional as an optimization? Should probably be documented in win_screenpos then, but I won't address that here. closes: #14191 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 13 Mar 2024 20:30:03 +0100
parents 5c220cf30f1f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim indent file
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
2 " Vim reST indent file
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
3 " Language: reStructuredText Documentation Format
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
4 " Maintainer: Marshall Ward <marshall.ward@gmail.com>
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
5 " Previous Maintainer: Nikolai Weibull <now@bitwi.se>
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
6 " Latest Revision: 2020-03-31
33052
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 19968
diff changeset
7 " 2023 Aug 28 by Vim Project (undo_indent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 setlocal indentexpr=GetRSTIndent()
375
f14cbd913415 updated for version 7.0097
vimboss
parents: 7
diff changeset
15 setlocal indentkeys=!^F,o,O
1216
35a1d7bd6191 updated for version 7.1b
vimboss
parents: 856
diff changeset
16 setlocal nosmartindent
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
33052
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 19968
diff changeset
18 let b:undo_indent = "setlocal indentexpr< indentkeys< smartindent<"
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 19968
diff changeset
19
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 if exists("*GetRSTIndent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
24 let s:itemization_pattern = '^\s*[-*+]\s'
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
25 let s:enumeration_pattern = '^\s*\%(\d\+\|#\)\.\s\+'
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
26 let s:note_pattern = '^\.\. '
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
27
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
28 function! s:get_paragraph_start()
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
29 let paragraph_mark_start = getpos("'{")[1]
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
30 return getline(paragraph_mark_start) =~ '\S' ? paragraph_mark_start : paragraph_mark_start + 1
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
31 endfunction
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
32
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 function GetRSTIndent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 let lnum = prevnonblank(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 let ind = indent(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let line = getline(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
42 let psnum = s:get_paragraph_start()
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
43 if psnum != 0
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
44 if getline(psnum) =~ s:note_pattern
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
45 let ind = 3
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
46 endif
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
47 endif
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 11062
diff changeset
48
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
49 if line =~ s:itemization_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
50 let ind += 2
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
51 elseif line =~ s:enumeration_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
52 let ind += matchend(line, s:enumeration_pattern)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 let line = getline(v:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
57 " Indent :FIELD: lines. Don’t match if there is no text after the field or
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
58 " if the text ends with a sent-ender.
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
59 if line =~ '^:.\+:\s\{-1,\}\S.\+[^.!?:]$'
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
60 return matchend(line, '^:.\{-1,}:\s\+')
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
61 endif
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
62
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 if line =~ '^\s*$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 execute lnum
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
65 call search('^\s*\%([-*+]\s\|\%(\d\+\|#\)\.\s\|\.\.\|$\)', 'bW')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let line = getline('.')
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
67 if line =~ s:itemization_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
68 let ind -= 2
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
69 elseif line =~ s:enumeration_pattern
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
70 let ind -= matchend(line, s:enumeration_pattern)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 elseif line =~ '^\s*\.\.'
3082
3502a7f991fc Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 1216
diff changeset
72 let ind -= 3
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 return ind
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 endfunction