Skip to content

Commit

Permalink
Step 33
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed May 30, 2024
1 parent 014aeb2 commit 620c2ac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lua/fittencode/engines/inline/model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ end
---@param lines string[]
---@return SuggestionsSegments?
local function get_region(lines, start, end_)
local segment = {}
local region = {}
for i, line in ipairs(lines) do
if i > end_[1] then
break
Expand All @@ -176,27 +176,27 @@ local function get_region(lines, start, end_)
-- ingore
elseif i >= start[1] then
if i == end_[1] then
segment[#segment + 1] = line:sub(start[2] + 1, end_[2]) or ''
region[#region + 1] = line:sub(start[2] + 1, end_[2]) or ''
else
if i == start[1] then
segment[#segment + 1] = line:sub(start[2] + 1) or ''
region[#region + 1] = line:sub(start[2] + 1) or ''
else
segment[#segment + 1] = line
region[#region + 1] = line
end
end
end
end
return segment
return region
end

---@return SuggestionsSegments?
local function make_segments(updated, utf_end)
local lines = updated.lines
local segments = updated.segments

local to_utf_end = function(cursor)
local correct = function(cursor)
if not cursor or not cursor[1] or not cursor[2] then
return nil
return { 0, 0 }
end
local ue = utf_end[cursor[1]]
if ue and ue[cursor[2]] and ue[cursor[2]] ~= 1 then
Expand All @@ -205,9 +205,9 @@ local function make_segments(updated, utf_end)
return cursor
end

local pre_commit = to_utf_end(segments.pre_commit)
local commit = to_utf_end(segments.commit)
local stage = to_utf_end(segments.stage)
local pre_commit = correct(segments.pre_commit)
local commit = correct(segments.commit)
local stage = correct(segments.stage)

if commit then
return {
Expand Down

0 comments on commit 620c2ac

Please sign in to comment.