Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lua/cmp/utils/str.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ INVALIDS[string.byte('\t')] = true
INVALIDS[string.byte('\n')] = true
INVALIDS[string.byte('\r')] = true

local NR_BYTE = string.byte('\n')

local PAIRS = {}
PAIRS[string.byte('<')] = string.byte('>')
PAIRS[string.byte('[')] = string.byte(']')
Expand Down Expand Up @@ -159,10 +157,9 @@ end
---@param text string
---@return string
str.oneline = function(text)
for i = 1, #text do
if string.byte(text, i) == NR_BYTE then
return string.sub(text, 1, i - 1)
end
local i = string.find(text, '\n', 1, true)
if i then
return string.sub(text, 1, i - 1)
end
return text
end
Expand Down