mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 03:45:42 +00:00
man.vim: clean up regex/string comparisons
- Explicitly specify case sensitivity when comparing strings - Clean up unnecessarily complex `if` statements
This commit is contained in:
@@ -51,7 +51,7 @@ function man#get_page(...) abort
|
|||||||
if winnr() > 1
|
if winnr() > 1
|
||||||
exe "norm! " . thiswin . "\<C-W>w"
|
exe "norm! " . thiswin . "\<C-W>w"
|
||||||
while 1
|
while 1
|
||||||
if &filetype == 'man'
|
if &filetype ==# 'man'
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
wincmd w
|
wincmd w
|
||||||
@@ -75,10 +75,10 @@ function man#get_page(...) abort
|
|||||||
endif
|
endif
|
||||||
silent exec 'r!/usr/bin/man '.s:cmd(sect, page).' | col -b'
|
silent exec 'r!/usr/bin/man '.s:cmd(sect, page).' | col -b'
|
||||||
" Remove blank lines from top and bottom.
|
" Remove blank lines from top and bottom.
|
||||||
while getline(1) =~ '^\s*$'
|
while getline(1) =~# '^\s*$'
|
||||||
silent keepjumps norm! gg"_dd
|
silent keepjumps norm! gg"_dd
|
||||||
endwhile
|
endwhile
|
||||||
while getline('$') =~ '^\s*$'
|
while getline('$') =~# '^\s*$'
|
||||||
silent keepjumps norm! G"_dd
|
silent keepjumps norm! G"_dd
|
||||||
endwhile
|
endwhile
|
||||||
setlocal nomodified
|
setlocal nomodified
|
||||||
@@ -133,10 +133,5 @@ endfunction
|
|||||||
|
|
||||||
function s:find_page(sect, page) abort
|
function s:find_page(sect, page) abort
|
||||||
let where = system('/usr/bin/man '.s:man_find_arg.' '.s:cmd(a:sect, a:page))
|
let where = system('/usr/bin/man '.s:man_find_arg.' '.s:cmd(a:sect, a:page))
|
||||||
if where !~ "^/"
|
return (where =~# '^ */')
|
||||||
if matchstr(where, " [^ ]*$") !~ "^ /"
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
return 1
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user