Skip to content

extmarks: complete() function modify extmarks accidentally #13816

@hrsh7th

Description

@hrsh7th
  • nvim --version:
NVIM v0.5.0-dev+1041-g1607dd071
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /Library/Developer/CommandLineTools/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/***/Develop/Repos/neovim/build/config -I/Users/***/Develop/Repos/neovim/src -I/Users/***/Develop/Repos/neovim/.deps/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include -I/usr/local/opt/gettext/include -I/Users/***/Develop/Repos/neovim/build/src/nvim/auto -I/Users/***/Develop/Repos/neovim/build/include
Compiled by ***@***.local

Features: +acl +iconv +tui
See ":help feature-compile"
Run :checkhealth for more info
  • vim -u DEFAULTS (version: ) behaves differently?
    • vim has no extmark features.
  • Operating system/version:
    • Mac/10.14.6
  • Terminal name/version:
    • iTerm2/3.4.3
  • $TERM:
    • xterm-256color

Steps to reproduce using nvim -u NORC

nvim -u NORC test.vim
:source %
test.vim
set completeopt=menu,menuone,noselect

inoremap <C-x> <C-r>=<SID>complete()<CR>
function! s:complete() abort
  call complete(2, [{ 'word': '/div_' }])
  return ''
endfunction

vnew
call setline(1, '</d>')

let s:ns = nvim_create_namespace('extmark-test')
call nvim_buf_set_extmark(bufnr('%'), s:ns, 0, 2, {
\   'end_line': 0,
\   'end_col': 3,
\ })

let s:prev_marks = nvim_buf_get_extmarks(bufnr('%'), s:ns, 0, -1, { 'details': v:true })
call feedkeys("1G3|a\<C-x>iv_", 'x')
let s:next_marks = nvim_buf_get_extmarks(bufnr('%'), s:ns, 0, -1, { 'details': v:true })

echomsg string({
\   'prev': s:prev_marks,
\   'next': s:next_marks,
\ })

Actual behaviour

{'prev': [[1, 0, 2, {'end_col': 3, 'end_row': 0}]], 'next': [[1, 0, 6, {'end_col': 1, 'end_row': 0}]]}

I think the next end_col is modified to pum start position accidentally.

Expected behaviour

{'prev': [[1, 0, 2, {'end_col': 3, 'end_row': 0}]], 'next': [[1, 0, 6, {'end_col': 2, 'end_row': 0}]]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    completionNvim built-in (omni)completionmarksmarks, extmarks, decorations, virtual text

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions