Skip to content

Conversation

@bew
Copy link
Contributor

@bew bew commented Jan 10, 2026

Extracted from #1396
Depends on #1420

@bew bew force-pushed the types-for-util-str branch from dff7c22 to c51c1d8 Compare January 10, 2026 17:43
@bew bew marked this pull request as ready for review January 10, 2026 18:56
--- Extract a rectangular block of lines in a multiline string area.
---@param lines string[]
---@param from LuaSnip.Pos00 From this position, MUST be within `lines`.
---@param to LuaSnip.Pos00 To this position (excluded), MUST be within `lines`
Copy link
Contributor Author

@bew bew Jan 10, 2026

Choose a reason for hiding this comment

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

should this use LuaSnip.RawPos00 instead ?

Copy link
Owner

Choose a reason for hiding this comment

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

Sounds reasonable, a buffer is also just a string[], so re-using that indexing scheme is appropriate 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in bb1c84d

function M.multiline_to_byte_offset(str, pos)
if pos[1] < 0 or pos[1] + 1 > #str or pos[2] < 0 then
---@param lines string[] a multiline string
---@param pos LuaSnip.ApiPosition an api-position relative to the start of str.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This LuaSnip.ApiPosition type is not defined 🤔 What do you want here?

Copy link
Owner

Choose a reason for hiding this comment

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

Should be RawPos00, I think I'm referring to api-indexing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in bb1c84d

still warning until #1420 is merged

end
end

-- FIXME(@L3MON4D3): not used anywhere?
Copy link
Owner

Choose a reason for hiding this comment

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

Oh yeah, leftover from a long time ago (13c5dce 👀)
We no longer use vimscript for registering these file-reload-autocommands, feel free to remove it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in bb1c84d

end

-- modifies strmod
-- FIXME(@L3MON4D3): not used anywhere?
Copy link
Owner

Choose a reason for hiding this comment

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

Yup, left over, get rid of it :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in bb1c84d

@L3MON4D3
Copy link
Owner

This is looking really good as well, great work ❤️

@bew bew changed the title util: Add types & docs for str utils util: Add types & docs for str utils, cleanup old functions Jan 18, 2026
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