Sfoglia il codice sorgente

Fix cursor handling with section headers

Marco Hinz 12 anni fa
parent
commit
1d5d2458d2
1 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 8 5
      autoload/startify.vim

+ 8 - 5
autoload/startify.vim

@@ -75,7 +75,7 @@ function! startify#insane_in_the_membrane() abort
   endif
   endif
 
 
   let cnt = 0
   let cnt = 0
-  let s:headoff = 0
+  let s:headoff = 2
 
 
   if exists('g:startify_custom_header')
   if exists('g:startify_custom_header')
     call append('$', g:startify_custom_header)
     call append('$', g:startify_custom_header)
@@ -139,7 +139,7 @@ function! startify#insane_in_the_membrane() abort
     autocmd startify BufReadPost * call s:restore_position()
     autocmd startify BufReadPost * call s:restore_position()
   endif
   endif
 
 
-  call cursor((s:show_special ? 4 : 2) + s:headoff, 5)
+  call cursor((s:show_special ? 2 : 0) + s:headoff, 5)
 
 
   silent! doautocmd <nomodeline> startify User
   silent! doautocmd <nomodeline> startify User
 endfunction
 endfunction
@@ -411,7 +411,10 @@ endfunction
 function! s:set_cursor() abort
 function! s:set_cursor() abort
   let s:oldline = exists('s:newline') ? s:newline : 5
   let s:oldline = exists('s:newline') ? s:newline : 5
   let s:newline = line('.')
   let s:newline = line('.')
-  let headoff   = s:headoff + 2 + s:secoff
+
+  if !exists('s:firstline')
+    let s:firstline = s:show_special ? s:headoff : (s:headoff + s:secoff)
+  endif
 
 
   " going down
   " going down
   if s:newline > s:oldline
   if s:newline > s:oldline
@@ -425,8 +428,8 @@ function! s:set_cursor() abort
     while index(s:section_header_lines, s:newline) != -1
     while index(s:section_header_lines, s:newline) != -1
       let s:newline -= 1
       let s:newline -= 1
     endwhile
     endwhile
-    if empty(getline(s:newline)) | let s:newline -= 1      | endif
-    if s:newline < headoff       | let s:newline = headoff | endif
+    if empty(getline(s:newline)) | let s:newline -= 1          | endif
+    if s:newline < s:firstline   | let s:newline = s:firstline | endif
   endif
   endif
 
 
   call cursor(s:newline, 5)
   call cursor(s:newline, 5)