Browse Source

Validate last buffer line of g:plug_window (#927)

Close #926

This fix shouldn't be necessary
because vim-plug's buffer should always have 4 lines
but a buffer can be modified in some cases
before nvim 0.4.0 and vim v8.1.1360.
Jan Edmund Lazo 6 years ago
parent
commit
2f5f74e5e6
1 changed files with 3 additions and 2 deletions
  1. 3 2
      plug.vim

+ 3 - 2
plug.vim

@@ -1338,9 +1338,10 @@ function! s:bar()
 endfunction
 
 function! s:logpos(name)
-  for i in range(4, line('$'))
+  let max = line('$')
+  for i in range(4, max > 4 ? max : 4)
     if getline(i) =~# '^[-+x*] '.a:name.':'
-      for j in range(i + 1, line('$'))
+      for j in range(i + 1, max > 5 ? max : 5)
         if getline(j) !~ '^ '
           return [i, j - 1]
         endif