Skip to content

Commit

Permalink
Unicode-terminated lines
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed May 22, 2024
1 parent 6e05b70 commit e7193ae
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/fittencode/engines/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,14 @@ local function normalize_range(buffer, range)
local byte_start = math.min(col + 1, #line)
local utf_index = Unicode.calculate_utf8_index(line)
local flag = utf_index[byte_start]
assert(flag == 0)
local byte_end = #line
local next = Unicode.find_zero(utf_index, byte_start + 1)
if next then
byte_end = next - 1
if flag == 0 then
local next = Unicode.find_zero(utf_index, byte_start + 1)
if next then
byte_end = next - 1
end
else
byte_end = byte_start
end
return byte_end
end
Expand Down

0 comments on commit e7193ae

Please sign in to comment.