Skip to content

Commit

Permalink
Add more log
Browse files Browse the repository at this point in the history
  • Loading branch information
luozhiya committed Jun 26, 2024
1 parent ebbb543 commit 14cfc85
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
7 changes: 3 additions & 4 deletions lua/fittencode/engines/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,9 @@ local function chain_actions(opts)
end
Promise:new(function(resolve, reject)
local task_id = _create_task(headless)
Sessions.request_generate_one_stage(task_id, prompt_ctx, function(_, prompt, suggestions)
Log.debug('Generated Suggestions: {}', suggestions)
local lines, ms = preprocessing(presug, task_id, headless, preprocess_format, suggestions)
Log.debug('Preprocessed Lines: {}', lines)
Sessions.request_generate_one_stage(task_id, prompt_ctx, function(id, prompt, suggestions)
local lines, ms = preprocessing(presug, id, headless, preprocess_format, suggestions)
Log.debug('ActionsEngine<{}> Preprocessed: {}, Generated: {}', string.format('%x', id), lines, suggestions)
elapsed_time = elapsed_time + ms
if not lines or #lines == 0 then
if extra_newline then
Expand Down
14 changes: 11 additions & 3 deletions lua/fittencode/engines/inline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ local function _generate_one_stage(row, col, on_success, on_error)
local ctx = PromptProviders.get_current_prompt_ctx(row, col)
Sessions.request_generate_one_stage(task_id, ctx, function(id, _, suggestions)
local lines = preprocessing(ctx, id, suggestions)
Log.debug('InlineEngine<{}> Preprocessed: {}', string.format('%x', id), lines)
if lines and #lines > 0 then
status:update(SC.SUGGESTIONS_READY)
apply_new_suggestions(task_id, row, col, lines)
Expand All @@ -209,14 +210,16 @@ end
---@param on_success? function
---@param on_error? function
function M.generate_one_stage(row, col, force, delaytime, on_success, on_error)
Log.debug('Start generating one stage')

if not force and model:cache_hit(row, col) and M.has_suggestions() then
status:update(SC.SUGGESTIONS_READY)
render_virt_text_segments(model:get_suggestions_segments())
schedule(on_success, model:make_new_trim_commmited_suggestions())
-- Log.debug('Cache hit')
Log.debug('CACHE HIT')
return
else
-- Log.debug('Cache miss')
Log.debug('CACHE MISS')
end

if inline_suggestions_ready() then
Expand Down Expand Up @@ -374,7 +377,12 @@ local function _accept_impl(range, direction, mode)
if mode == 'stage' then
set_text_event_filter(segments.stage)
end
M.reset()
M:reset()
if Config.options.inline_completion.auto_triggering_completion then
-- generate_one_stage_current_force()
else
ignore_cursor = { Base.get_cursor() }
end
else
render_virt_text_segments(segments)
end
Expand Down
6 changes: 3 additions & 3 deletions lua/fittencode/tasks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ function TaskScheduler:create(row, col)
local timestamp = uv.hrtime()
table.insert(self.list, #self.list + 1, { row = row, col = col, timestamp = timestamp })
if row and col then
-- Log.debug('Task<{}>: {} Created at ({}, {})', self.tag, string.format('%x', timestamp), row, col)
Log.debug('Task<{}>: {} Created at ({}, {})', self.tag, string.format('%x', timestamp), row, col)
else
-- Log.debug('Task<{}>: {} Created', self.tag, string.format('%x', timestamp))
Log.debug('Task<{}>: {} Created', self.tag, string.format('%x', timestamp))
end
return timestamp
end
Expand All @@ -79,7 +79,7 @@ function TaskScheduler:match_clean(task_id, row, col, clean)
local task = self.list[i]
if task.timestamp == task_id and task.row == row and task.col == col then
ms = math.floor((uv.hrtime() - task.timestamp) / MS_TO_NS)
-- Log.debug('Task<{}>: {} Matched, Time elapsed: {} ms', self.tag, string.format('%x', task_id), ms)
Log.debug('Task<{}>: {} Matched, Time elapsed: {} ms', self.tag, string.format('%x', task_id), ms)
match_found = true
break
end
Expand Down

0 comments on commit 14cfc85

Please sign in to comment.