Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim9: cannot write block in autoload script sourced while calling omni completion function #8631

Closed
lacygoill opened this issue Jul 24, 2021 · 0 comments

Comments

@lacygoill
Copy link

Describe the bug

In Vim9 script, we cannot write a block in an autoload script sourced while calling an omni completion function.

To Reproduce

Run this shell command:

vim -Nu NONE -S <(cat <<'EOF'
    vim9script
    set rtp=/tmp/some
    var dir = '/tmp/some/autoload'
    mkdir(dir, 'p')
    var lines =<< trim END
        vim9script
        def omni#func(findstart: bool, base: string): any
            if findstart
                return 1
            else
                return ['match']
            endif
        enddef
        {
            eval 1 + 2
        }
    END
    writefile(lines, dir .. '/omni.vim')
    &l:omnifunc = 'omni#func'
    startinsert
    feedkeys("\<C-X>\<C-O>")
EOF
)

The error E565 is given:

E565: Not allowed to change text or change window: {

Expected behavior

No error is given. match is inserted in the buffer.

Environment

  • Vim version: 8.2 Included patches: 1-3215
  • OS: Ubuntu 20.04.2 LTS
  • Terminal: XTerm(353)

Additional context

No issue if the block is removed:

vim9script
set rtp=/tmp/some
var dir = '/tmp/some/autoload'
mkdir(dir, 'p')
var lines =<< trim END
    vim9script
    def omni#func(findstart: bool, base: string): any
        if findstart
            return 1
        else
            return ['match']
        endif
    enddef
END
writefile(lines, dir .. '/omni.vim')
&l:omnifunc = 'omni#func'
startinsert
feedkeys("\<C-X>\<C-O>")
no error

No issue if the omnifunc is moved in a non-autoloaded script:

vim9script
def g:OmniFunc(findstart: bool, base: string): any
    if findstart
        return 1
    else
        return ['match']
    endif
enddef
{
    eval 1 + 2
}
&l:omnifunc = 'g:OmniFunc'
startinsert
feedkeys("\<C-X>\<C-O>")
no error
chrisbra pushed a commit to chrisbra/vim that referenced this issue Aug 30, 2021
Problem:    Vim: using {} block in autoloade omnifunc fails.
Solution:   Allow using {} block when text is locked. (closes vim#8631)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant