Mercurial > vim
view runtime/indent/context.vim @ 34383:a84fe48ae523 v9.1.0118
patch 9.1.0118: Use different restoration strategy in win_splitmove
Commit: https://github.com/vim/vim/commit/704966c2545897dfcf426dd9ef946aeb6fa80c38
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date: Tue Feb 20 22:00:33 2024 +0100
patch 9.1.0118: Use different restoration strategy in win_splitmove
Problem: saving and restoring all frames to split-move is overkill now
that WinNewPre is not fired when split-moving.
Solution: defer the flattening of frames until win_split_ins begins
reorganising them, and attempt to restore the layout by
undoing our changes. (Sean Dewar)
This also means we no longer must allocate.
related: #14042
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 | Tue, 20 Feb 2024 22:30:07 +0100 |
parents | d81556766132 |
children |
line wrap: on
line source
vim9script # Language: ConTeXt typesetting engine # Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com> # Former Maintainers: Nikolai Weibull <now@bitwi.se> # Latest Revision: 2023 Dec 26 if exists("b:did_indent") finish endif # Load MetaPost indentation script (this will also set b:did_indent) runtime! indent/mp.vim setlocal indentexpr=ConTeXtIndent() b:undo_indent = "setl indentexpr<" def PrevNotComment(l: number): number var prevlnum = prevnonblank(l) while prevlnum > 0 && getline(prevlnum) =~# '^\s*%' prevlnum = prevnonblank(prevlnum - 1) endwhile return prevlnum enddef def FindPair(pstart: string, pmid: string, pend: string): number cursor(v:lnum, 1) return indent(searchpair(pstart, pmid, pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')) enddef def ConTeXtIndent(): number # Use MetaPost rules inside MetaPost graphic environments if len(synstack(v:lnum, 1)) > 0 && synIDattr(synstack(v:lnum, 1)[0], "name") ==# 'contextMPGraphic' return g:MetaPostIndent() endif const prevlnum = PrevNotComment(v:lnum - 1) const prevind = indent(prevlnum) const prevline = getline(prevlnum) const currline = getline(v:lnum) # If the current line starts with ], match indentation. if currline =~# '^\s*\]' return FindPair('\[', '', '\]') endif # If the current line starts with }, match indentation. if currline =~# '^\s*}' return FindPair('{', '', '}') endif # If the previous line ends with [ or { (possibly followed by a comment) then indent. if prevline =~# '[{[]\s*\%(%.*\)\=$' return prevind + shiftwidth() endif return -1 enddef # vim: sw=2 fdm=marker