Skip to content

Commit

Permalink
perf(selection): reduce the number of times indentation is calculated (
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone authored Aug 31, 2024
1 parent 2a0a868 commit 6b11ac7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lua/avante/selection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,14 @@ function Selection:create_editing_input()

local original_first_line_indentation = Utils.get_indentation(code_lines[self.selection.range.start.line])

local need_prepend_indentation = false

api.nvim_exec_autocmds("User", { pattern = EDITING_INPUT_START_SPINNER_PATTERN })
---@type AvanteChunkParser
local on_chunk = function(chunk)
full_response = full_response .. chunk
local response_lines = vim.split(full_response, "\n")
local need_prepend_indentation = false
if #response_lines > 0 then
if #response_lines == 1 then
local first_line = response_lines[1]
local first_line_indentation = Utils.get_indentation(first_line)
need_prepend_indentation = first_line_indentation ~= original_first_line_indentation
Expand Down

0 comments on commit 6b11ac7

Please sign in to comment.