JuliaEditorSupport / julia-vim

Vim support for Julia.
http://julialang.org/
Other
752 stars 94 forks source link

Block detection should be case sensitive about keywords #279

Closed digital-carver closed 2 years ago

digital-carver commented 2 years ago

The block movement commands, for eg. moveblock_n, moveblock_N, etc., treat type annotation Function as if it were the start of a new function, and so on (if the user has set ignorecase on). Moving with ]] (or [[, etc.) through

"""
"""
function findlast(testf::Function, A)
    for (i, a) in Iterators.reverse(pairs(A))
        testf(a) && return i
    end
    return nothing
end

findlast(testf::Function, A::Union{AbstractArray, AbstractString}, b::Begin) =
    findprev(testf, A, last(keys(A)))

with the cursor originally at the top, the cursor will stop at four points: first (correctly) at the beginning of function findlast, then at the Function annotation of the testf argument, then at the next Function annotation and then at the Begin type annotation (that I made up for this illustration).

I think this happens because these movements ultimately call moveto_block_delim (in autoload/julia_blocks.vim), and that uses the search function to look for the block starting keywords. And according to Vim documentation, "'ignorecase', 'smartcase' and 'magic' are used" by search automatically.

A fix should be to save the user's ignorecase preference, set noignorecase before the search and searchpair calls in this file (and other files if any), and then restore the original ignorecase preference.

carlobaldassi commented 2 years ago

Thanks for reporting this. I forced case-sensitivity within the patterns themselves. Hopefully it's fixed in all cases, otherwise I'll reopen.