1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:40:05 +08:00

Fix cursor indicator

This commit is contained in:
wsdjeg 2018-03-25 19:03:22 +08:00
parent 70a9d81eac
commit c0ea6fa673

View File

@ -227,6 +227,21 @@ else
endfunction
endif
function! s:search_status() abort
let ct = 0
let tt = 0
let ctl = split(s:VIMCOMP.execute('keeppatterns .,$s/' . @/ . '//gn', 'silent!'), "\n")
if !empty(ctl)
let ct = split(ctl[0])[0]
endif
let ttl = split(s:VIMCOMP.execute('keeppatterns %s/' . @/ . '//gn', 'silent!'), "\n")
if !empty(ctl)
let tt = split(ttl[0])[0]
endif
return ' ' . (str2nr(tt) - str2nr(ct) + 1) . '/' . tt . ' '
endfunction
let s:registed_sections = {
\ 'winnr' : function('s:winnr'),
\ 'syntax checking' : function('s:syntax_checking'),
@ -240,6 +255,7 @@ let s:registed_sections = {
\ 'date' : function('s:date'),
\ 'whitespace' : function('s:whitespace'),
\ 'battery status' : function('s:battery_status'),
\ 'search status' : function('s:search_status'),
\ }
@ -264,21 +280,6 @@ function! s:buffer_name() abort
endif
endfunction
function! s:search_status() abort
let ct = 0
let tt = 0
let ctl = split(s:VIMCOMP.execute('keeppatterns .,$s/' . @/ . '//gn', 'silent!'), "\n")
if !empty(ctl)
let ct = split(ctl[0])[0]
endif
let ttl = split(s:VIMCOMP.execute('keeppatterns %s/' . @/ . '//gn', 'silent!'), "\n")
if !empty(ctl)
let tt = split(ttl[0])[0]
endif
return ' ' . (str2nr(tt) - str2nr(ct) + 1) . '/' . tt . ' '
endfunction
function! s:filesize() abort
let l:size = getfsize(bufname('%'))
@ -467,7 +468,11 @@ function! SpaceVim#layers#core#statusline#toggle_section(name) abort
if index(s:loaded_sections_l, a:name) == -1
\ && index(s:loaded_sections_r, a:name) == -1
\ && !has_key(s:section_old_pos, a:name)
call add(s:loaded_sections_r, a:name)
if a:name ==# 'search status'
call insert(s:loaded_sections_l, a:name, 2)
else
call add(s:loaded_sections_r, a:name)
endif
elseif index(s:loaded_sections_r, a:name) != -1
let s:section_old_pos[a:name] = ['r', index(s:loaded_sections_r, a:name)]
call remove(s:loaded_sections_r, index(s:loaded_sections_r, a:name))