Skip to content

A snippet with i(1, "é") fails with error index out of range #1308

@bew

Description

@bew

Hello!

Given I use an insert node as a snippet, with a non-ascii default value..

When I try to expand a snippet I get this error:

E5108: Error executing lua: .../managed-plugins/start/LuaSnip/lua/luasnip/util/util.lua:406: attempt to index local 'offset' (a nil value)
stack traceback:
        .../managed-plugins/start/LuaSnip/lua/luasnip/util/util.lua:406: in function 'pos_from_offset'
        ...managed-plugins/start/LuaSnip/lua/luasnip/nodes/util.lua:1017: in function 'restore_cursor_pos_relative'
        ...m-wip/managed-plugins/start/LuaSnip/lua/luasnip/init.lua:206: in function 'node_update_dependents_preserve_position'
        ...m-wip/managed-plugins/start/LuaSnip/lua/luasnip/init.lua:319: in function 'update_dependents'
        ...m-wip/managed-plugins/start/LuaSnip/lua/luasnip/init.lua:336: in function '_active_update_dependents'
        ...m-wip/managed-plugins/start/LuaSnip/lua/luasnip/init.lua:539: in function '_snip_expand'
        ...m-wip/managed-plugins/start/LuaSnip/lua/luasnip/init.lua:581: in function 'fn'
        ...m-wip/managed-plugins/start/LuaSnip/lua/luasnip/init.lua:51: in function 'expand'
        ...ew/.config/nvim-wip/lua/mycfg/plugs_for_file_editing.lua:557: in function <...ew/.config/nvim-wip/lua/mycfg/plugs_for_file_editing.lua:556>

Then when I dismiss the error I see that the snippet was actually inserted into the buffer, but the mode is still insert (instead of select), and the cursor is located at the beginning of the snippet.
Also when the node is not the first tabstop, I don't get any error but the behavior isn't better..

(note: initially discovered this trying to use (ellipsis character), but it looks like é triggers the issue as well so it might be generalized)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions