Skip to content

Conversation

@bew
Copy link
Contributor

@bew bew commented Jan 10, 2026

Extracted from #1396 (and reworked a little)

  • Rework position types
  • Add types for all Mark utils
  • Remove unused Mark:update method (ref)

---@param p2 LuaSnip.RawPos00|LuaSnip.Pos00
---@return boolean
--
-- FIXME(@bew): I don't know how to enforce the use of the same type of pos..
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be doable via @overload, but I'm not getting the correct results with this simple example

---@param a number
---@param b number
---@return boolean
---@overload fun(table,table) : boolean
local function test(a, b) return a == b end

test(1,{})

Comment on lines 457 to 458
-- FIXME(@L3MON4D3): Is this documentation correct? It looks the same as
-- `pos_offset` above 🤔
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, no it is incorrect, good catch 👍

pos_from_offset computes the end-position of text with offset[1] lines and offset[2] columns in the last line inserted at base_pos. So, something of an inverse to pos_offset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make a full suggestion to replace the doc of that function?
(I don't have the brain power to think much to rewrite that doc right now 👀)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure :)

--- Given an offset computed via `pos_offset`, compute its position when
--- applied to `base_pos`.

We use pos_offset to store the cursor-position relative to the node it is currently in, and then pos_from_offset to recover the cursor at a new node-position base_pos (store_cursor_node_relative, restore_cursor_pos_relative)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in f079e72

@bew
Copy link
Contributor Author

bew commented Jan 23, 2026

could we get this merged ? it's an important one to get the ball rolling ;)

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

Successfully merging this pull request may close these issues.

2 participants