Skip to content

Commit

Permalink
Step 75
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed Jun 2, 2024
1 parent 2f3e0c2 commit 12354aa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
56 changes: 28 additions & 28 deletions lua/fittencode/engines/inline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function M.has_suggestions()
return model:has_suggestions()
end

---@return SuggestionsCache
---@return string[]
function M.get_suggestions()
return model:get_suggestions() or {}
end
Expand Down Expand Up @@ -397,28 +397,6 @@ function M.reset()
tasks:clear()
end

local function _on_cursor_moved()
if Lines.is_rendering(api.nvim_get_current_buf(), extmark_ids[IDS_PROMPT]) then
clear_virt_text_prompt()
end
if not suggestions_modify_enabled() then
return
end
if not model:cache_hit(Base.get_cursor()) then
clear_virt_text_all()
model:reset()
end
end

function M.on_cursor_moved()
if ignore_event then
return
end
Base.debounce(cursormoved_timer, function()
_on_cursor_moved()
end, CURSORMOVED_DEBOUNCE_TIME)
end

---@return boolean
function M.is_inline_enabled()
if Config.options.completion_mode ~= 'inline' then
Expand All @@ -434,6 +412,11 @@ function M.is_inline_enabled()
return true
end

---@return integer
function M.get_status()
return status:get_current()
end

---@return boolean?
function M.on_text_changed()
if ignore_event then
Expand Down Expand Up @@ -471,11 +454,6 @@ function M.on_text_changed()
end
end

---@return integer
function M.get_status()
return status:get_current()
end

function M.on_leave()
M.reset()
end
Expand Down Expand Up @@ -516,4 +494,26 @@ function M.on_cursor_hold()
M.generate_one_stage(row, col)
end

local function _on_cursor_moved()
if Lines.is_rendering(api.nvim_get_current_buf(), extmark_ids[IDS_PROMPT]) then
clear_virt_text_prompt()
end
if not suggestions_modify_enabled() then
return
end
if not model:cache_hit(Base.get_cursor()) then
clear_virt_text_all()
model:reset()
end
end

function M.on_cursor_moved()
if ignore_event then
return
end
Base.debounce(cursormoved_timer, function()
_on_cursor_moved()
end, CURSORMOVED_DEBOUNCE_TIME)
end

return M
2 changes: 1 addition & 1 deletion lua/fittencode/views/lines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function M.render_virt_text(opts)
local show_time = opts.show_time or 0
local hls = opts.hls or {}
local hl_mode = opts.hl_mode or 'combine'
local center_vertical = opts.center_vertical or true
local center_vertical = opts.center_vertical ~= false or false

if #lines == 0 then
return
Expand Down

0 comments on commit 12354aa

Please sign in to comment.