Fix #2330 - Do not use getcurpos() to avoid changing curswant

This commit is contained in:
w0rp 2019-03-07 12:28:36 +00:00
parent 6aef52f026
commit 5505f2323d
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
11 changed files with 19 additions and 19 deletions

View File

@ -236,7 +236,7 @@ function! ale#completion#Show(response, completion_parser) abort
endfunction
function! s:CompletionStillValid(request_id) abort
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
return ale#util#Mode() is# 'i'
\&& has_key(b:, 'ale_completion_info')
@ -514,7 +514,7 @@ endfunction
" This function can be used to manually trigger autocomplete, even when
" g:ale_completion_enabled is set to false
function! ale#completion#AlwaysGetCompletions(need_prefix) abort
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)
@ -546,7 +546,7 @@ endfunction
function! s:TimerHandler(...) abort
let s:timer_id = -1
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
" When running the timer callback, we have to be sure that the cursor
" hasn't moved from where it was when we requested completions by typing.
@ -569,7 +569,7 @@ function! ale#completion#Queue() abort
return
endif
let s:timer_pos = getcurpos()[1:2]
let s:timer_pos = getpos('.')[1:2]
if s:timer_pos == s:last_done_pos
" Do not ask for completions if the cursor rests on the position we
@ -593,7 +593,7 @@ function! ale#completion#Done() abort
call ale#completion#RestoreCompletionOptions()
let s:last_done_pos = getcurpos()[1:2]
let s:last_done_pos = getpos('.')[1:2]
endfunction
function! s:Setup(enabled) abort

View File

@ -22,7 +22,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort
let l:shortmess_options = &l:shortmess
try
let l:cursor_position = getcurpos()
let l:cursor_position = getpos('.')
" The message is truncated and saved to the history.
setlocal shortmess+=T
@ -44,7 +44,7 @@ function! ale#cursor#TruncatedEcho(original_message) abort
" Reset the cursor position if we moved off the end of the line.
" Using :norm and :echomsg can move the cursor off the end of the
" line.
if l:cursor_position != getcurpos()
if l:cursor_position != getpos('.')
call setpos('.', l:cursor_position)
endif
finally
@ -114,7 +114,7 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort
call s:StopCursorTimer()
let l:pos = getcurpos()[0:2]
let l:pos = getpos('.')[0:2]
" Check the current buffer, line, and column number against the last
" recorded position. If the position has actually changed, *then*

View File

@ -104,7 +104,7 @@ endfunction
function! s:GoToLSPDefinition(linter, options, capability) abort
let l:buffer = bufnr('')
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
let l:column = min([l:column, len(getline(l:line))])
let l:Callback = function(

View File

@ -57,7 +57,7 @@ function! ale#hover#HandleLSPResponse(conn_id, response) abort
" If the call did __not__ come from balloonexpr...
if !get(l:options, 'hover_from_balloonexpr', 0)
let l:buffer = bufnr('')
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
let l:end = len(getline(l:line))
if l:buffer isnot l:options.buffer
@ -174,7 +174,7 @@ endfunction
" This function implements the :ALEHover command.
function! ale#hover#ShowAtCursor() abort
let l:buffer = bufnr('')
let l:pos = getcurpos()
let l:pos = getpos('.')
call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {})
endfunction
@ -182,7 +182,7 @@ endfunction
" This function implements the :ALEDocumentation command.
function! ale#hover#ShowDocumentationAtCursor() abort
let l:buffer = bufnr('')
let l:pos = getcurpos()
let l:pos = getpos('.')
let l:options = {'show_documentation': 1}
call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], l:options)

View File

@ -11,7 +11,7 @@
" be returned.
function! ale#loclist_jumping#FindNearest(direction, wrap, ...) abort
let l:buffer = bufnr('')
let l:pos = getcurpos()
let l:pos = getpos('.')
let l:info = get(g:ale_buffer_info, bufnr('%'), {'loclist': []})
" Copy the list and filter to only the items in this buffer.
let l:loclist = filter(copy(l:info.loclist), 'v:val.bufnr == l:buffer')

View File

@ -5,7 +5,7 @@
" [is_notification, method_name, params?]
"
" All functions which accept line and column arguments expect them to be 1-based
" (the same format as being returned by getcurpos() and friends), those then
" (the same format as being returned by getpos() and friends), those then
" will be converted to 0-based as specified by LSP.
let g:ale_lsp_next_version_id = 1

View File

@ -71,7 +71,7 @@ endfunction
function! s:Open(open_in_tab) abort
let l:item_list = get(b:, 'ale_preview_item_list', [])
let l:item = get(l:item_list, getcurpos()[1] - 1, {})
let l:item = get(l:item_list, getpos('.')[1] - 1, {})
if empty(l:item)
return

View File

@ -113,7 +113,7 @@ function! ale#references#Find(...) abort
endif
let l:buffer = bufnr('')
let [l:line, l:column] = getcurpos()[1:2]
let [l:line, l:column] = getpos('.')[1:2]
let l:column = min([l:column, len(getline(l:line))])
let l:Callback = function('s:OnReady', [l:line, l:column, l:options])

View File

@ -470,7 +470,7 @@ endfunction
function! ale#util#FindItemAtCursor(buffer) abort
let l:info = get(g:ale_buffer_info, a:buffer, {})
let l:loclist = get(l:info, 'loclist', [])
let l:pos = getcurpos()
let l:pos = getpos('.')
let l:index = ale#util#BinarySearch(l:loclist, a:buffer, l:pos[1], l:pos[2])
let l:loc = l:index >= 0 ? l:loclist[l:index] : {}

View File

@ -47,7 +47,6 @@ function! ale#virtualtext#ShowMessage(message, hl_group) abort
return
endif
let l:cursor_position = getcurpos()
let l:line = line('.')
let l:buffer = bufnr('')
let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
@ -117,7 +116,7 @@ function! ale#virtualtext#ShowCursorWarningWithDelay() abort
call s:StopCursorTimer()
let l:pos = getcurpos()[0:2]
let l:pos = getpos('.')[0:2]
" Check the current buffer, line, and column number against the last
" recorded position. If the position has actually changed, *then*

View File

@ -106,6 +106,7 @@ check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<li
check_errors 'shellescape(' 'Use ale#Escape instead of shellescape'
check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify'
check_errors 'tempname(' 'Use ale#util#Tempname instead of tempname'
check_errors 'getcurpos(' "Use getpos('.') instead of getcurpos() if you don't need curswant, to avoid a bug that changes curswant"
check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer."
check_errors 'getcwd()' "Do not use getcwd(), as it could run from the wrong buffer. Use expand('#' . a:buffer . ':p:h') instead."
check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true"