view runtime/indent/postscr.vim @ 19627:6b1564fcab92 v8.2.0370

patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset Commit: https://github.com/vim/vim/commit/e49b4bb89505fad28cf89f0891aef3e2d397919e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 11 13:01:40 2020 +0100 patch 8.2.0370: the typebuf_was_filled flag is sometimes not reset Problem: The typebuf_was_filled flag is sometimes not reset, which may cause a hang. Solution: Make sure typebuf_was_filled is reset when the typeahead buffer is empty.
author Bram Moolenaar <Bram@vim.org>
date Wed, 11 Mar 2020 13:15:04 +0100
parents 63b0b7b79b25
children 9c221ad9634a
line wrap: on
line source

" PostScript indent file
" Language:    PostScript
" Maintainer:  Mike Williams <mrw@netcomuk.co.uk>
" Last Change: 2nd July 2001
"

" Only load this indent file when no other was loaded.
if exists("b:did_indent")
  finish
endif
let b:did_indent = 1

setlocal indentexpr=PostscrIndentGet(v:lnum)
setlocal indentkeys+=0],0=>>,0=%%,0=end,0=restore,0=grestore indentkeys-=:,0#,e

" Catch multiple instantiations
if exists("*PostscrIndentGet")
  finish
endif

function! PostscrIndentGet(lnum)
  " Find a non-empty non-comment line above the current line.
  " Note: ignores DSC comments as well!
  let lnum = a:lnum - 1
  while lnum != 0
    let lnum = prevnonblank(lnum)
    if getline(lnum) !~ '^\s*%.*$'
      break
    endif
    let lnum = lnum - 1
  endwhile

  " Hit the start of the file, use user indent.
  if lnum == 0
    return -1
  endif

  " Start with the indent of the previous line
  let ind = indent(lnum)
  let pline = getline(lnum)

  " Indent for dicts, arrays, and saves with possible trailing comment
  if pline =~ '\(begin\|<<\|g\=save\|{\|[\)\s*\(%.*\)\=$'
    let ind = ind + shiftwidth()
  endif

  " Remove indent for popped dicts, and restores.
  if pline =~ '\(end\|g\=restore\)\s*$'
    let ind = ind - shiftwidth()

  " Else handle immediate dedents of dicts, restores, and arrays.
  elseif getline(a:lnum) =~ '\(end\|>>\|g\=restore\|}\|]\)'
    let ind = ind - shiftwidth()

  " Else handle DSC comments - always start of line.
  elseif getline(a:lnum) =~ '^\s*%%'
    let ind = 0
  endif

  " For now catch excessive left indents if they occur.
  if ind < 0
    let ind = -1
  endif

  return ind
endfunction

" vim:sw=2