yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
6.82k stars 247 forks source link

bug: unable to apply changes, nothing happens #601

Open matthewblott opened 1 month ago

matthewblott commented 1 month ago

Describe the bug

I have a file foo.rb which contains the following code:

def add(j, i)
  j + i
end

I asked Avante chat to produce a minus function which it does and also presents me with a button to apply the changes that looks like the following:

[: apply this, : apply all]

However if I try and press the button nothing happens and nothing happens if I press the 'a' key or shift + 'a'.

To reproduce

My config is pretty simple, just two files:

The plugins.lua file:

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'

if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  }
end

vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    'nvim-telescope/telescope.nvim',
    branch = '0.1.x',
    dependencies = { 'nvim-lua/plenary.nvim' },
  },
  { 
    'nvim-telescope/telescope-fzf-native.nvim',
    build = 'make' 
  },
  {
    'camgraff/telescope-tmux.nvim',
    lazy = false,
    dependencies = {
      'norcalli/nvim-terminal.lua',
    },
  },
  {
    -- Highlight, edit, and navigate code
    'nvim-treesitter/nvim-treesitter',
    dependencies = {
    'nvim-treesitter/nvim-treesitter-textobjects',
  },
    build = ':TSUpdate',
  },
  {
    -- File explorer
    'nvim-tree/nvim-tree.lua',
    version = '*',
    lazy = false,
    dependencies = {
      'nvim-tree/nvim-web-devicons',
      'b0o/nvim-tree-preview.lua',
    },
  },
  {
    -- Theme
    'loctvl842/monokai-pro.nvim',
  },
  {
    -- Working with tabs
    'romgrk/barbar.nvim',
  },
  { 
    -- Make sure the christoomey/vim-tmux-navigator
    -- plugin is installed and the keymappings are set
    'mrjones2014/smart-splits.nvim' 
  },
  {
    'numToStr/Comment.nvim',
    lazy = false,
  },
  {
    -- For working with text
    'preservim/vim-pencil',
  },
  {
    'windwp/nvim-autopairs',
    event = 'InsertEnter',
    config = true
  },
  {'williamboman/mason.nvim'},
  {'williamboman/mason-lspconfig.nvim'},
  {'VonHeikemen/lsp-zero.nvim', branch = 'v3.x'},
  {'neovim/nvim-lspconfig'},
  {'hrsh7th/cmp-nvim-lsp'},
  {'hrsh7th/nvim-cmp'},
  {'L3MON4D3/LuaSnip'},
  {
    'yetone/avante.nvim',
    event = 'VeryLazy',
    lazy = false,
    version = false, 
    opts = {
      provider = "openai",
    },
    build = 'make BUILD_FROM_SOURCE=true',
    dependencies = {
      'stevearc/dressing.nvim',
      'nvim-lua/plenary.nvim',
      'MunifTanjim/nui.nvim',
      {
        'MeanderingProgrammer/render-markdown.nvim',
        opts = {
          file_types = { 'markdown', 'Avante' },
        },
        ft = { 'markdown', 'Avante' },
      },
    },
  },

}) 

The config.lua file:

-- =============================================================================
-- General
-- =============================================================================

-- Added for the file preview window because updating is too slow to load
vim.opt.updatetime = 100

-- Make line numbers default

-- window options
vim.wo.number = true
vim.wo.relativenumber = true

-- Options
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
-- Use spaces instead of tabs
vim.opt.expandtab = true

-- Sync clipboard between OS and Neovim.
vim.opt.clipboard = 'unnamedplus'

-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.opt.ignorecase = true
vim.opt.smartcase = true

-- Don't wrap lines by default
vim.opt.wrap = false

-- =============================================================================
-- Colour Scheme
-- =============================================================================

-- tmux causes a horrible clash with monokai that needs fixing
-- See https://www.elliottchenstudio.com/blog/neovim-true-color
-- Add the following entries to tmux.conf:
-- set -g default-terminal "xterm-256color"
-- set-option -ga terminal-overrides ",xterm*:Tc"
vim.cmd([[colorscheme monokai-pro]])

-- =============================================================================
-- Key Mappings
-- =============================================================================

local opts = { noremap = true, silent = true }
local term_opts = { silent = true }
local keymap = vim.api.nvim_set_keymap

-- Leader Key
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

keymap('n', 'a', '$A', opts)
keymap('n', 'o', 'o<esc>', opts)
keymap('n', '<s-o>', 'O<esc>', opts)

keymap('i', 'kj', '<esc>', opts)
keymap('n', '<leader>w', '<cmd>write<cr>', opts)

-- Window Navigation
keymap('n', '<C-h>', '<C-w>h', opts)
keymap('n', '<C-j>', '<C-w>j', opts)
keymap('n', '<C-k>', '<C-w>k', opts)
keymap('n', '<C-l>', '<C-w>l', opts)

-- Indentation
keymap('v', '<tab>', '>gv', opts)
keymap('v', '<s-tab>', '<gv', opts)

-- =============================================================================
-- Telescope
-- =============================================================================

local telescope = require('telescope')

telescope.setup()
telescope.load_extension('fzf')

local builtin = require('telescope.builtin')

vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fF', '', { callback = function() builtin.find_files({ hidden = true, no_ignore = true }) end, desc = "Find files" })
vim.keymap.set('n', '<leader>fw', builtin .live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin .buffers, {})
vim.keymap.set('n', '<leader>fh', builtin .help_tags, {})

-- =============================================================================
-- NVim Tree
-- =============================================================================

-- Disable netrw (recommended when using nvim tree)

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

local preview = require('nvim-tree-preview')

local function tree_on_attach(bufnr)
  local api = require('nvim-tree.api')

  local function opts(desc)
    return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
  end

  local function toggle_node_if_directory()
    local current_node = api.tree.get_node_under_cursor()
    -- local node = api.tree.get_node_under_cursor()
    if current_node.type == 'directory' then
      api.node.open.tab()
    end
  end

  local function handle_node()
    local current_node = api.tree.get_node_under_cursor()
    -- if not current_node then
    --   print("No node selected")
    --   return
    -- end

    -- Get the full path of the selected node
    local node_path = current_node.absolute_path

    -- Execute the bash script with the node path as an argument
    local cmd = string.format("bash ${HOME}/.local/bin/del '%s'", node_path)
    os.execute(cmd)
  end

  -- default mappings
  api.config.mappings.default_on_attach(bufnr)

  vim.keymap.set('n', 'y', api.fs.copy.node, opts('Copy node'))
  vim.keymap.set('n', 'n', api.fs.create, opts('New file'))

  vim.keymap.set('n', 'd', handle_node, opts('Delete file'))

  vim.keymap.set('n', 'h', toggle_node_if_directory, opts('Close node'))
  vim.keymap.set('n', 'l', toggle_node_if_directory, opts('Open node'))
  vim.keymap.set('n', 'm', api.fs.rename_full, opts('Move'))
  vim.keymap.set('n', '<s-p>', api.node.open.preview, opts('Preview'))

  -- nvim-tree-preview
  vim.keymap.set('n', 'P', preview.watch, opts 'Preview (Watch)')
  vim.keymap.set('n', '<esc>', preview.unwatch, opts 'Close Preview/Unwatch')
  vim.keymap.set('n', '<tab>', function()
    local ok, node = pcall(api.tree.get_node_under_cursor)
    if ok and node then
      if node.type == 'directory' then
        api.node.open.edit()
      else
        preview.node(node, { toggle_focus = true })
      end
    end
  end, opts 'Preview')

end

local tree = require('nvim-tree')

tree.setup({
  -- Although on_attach isn't called here without the line below the keymappings above will not work.
  on_attach = tree_on_attach,
  actions = {
    open_file = {
      resize_window = false, -- Prevent the window from resizing when opening a file
    },
  },
})

local tree_api = require('nvim-tree.api')

vim.keymap.set('n', '<leader>e', tree_api.tree.toggle, {})

-- =============================================================================
-- Barbar
-- =============================================================================

local barbar = require('barbar')

barbar.setup()

vim.keymap.set('n', '<s-l>', '<cmd>BufferNext<cr>', {})
vim.keymap.set('n', '<s-h>', '<cmd>BufferPrevious<cr>', {})
vim.keymap.set('n', '<leader>c', '<cmd>BufferClose<cr>', {})
vim.keymap.set('n', '<leader>v', '<cmd>BufferCloseAllButCurrent<cr>', {})

-- =============================================================================
-- Comment 
-- =============================================================================

local comment = require('Comment')

comment.setup()

local comment_api = require('Comment.api')

vim.keymap.set('n', '<leader>/', function() comment_api.toggle.linewise.count(vim.v.count > 0 and vim.v.count or 1) end, {})
vim.keymap.set('v', '<leader>/', "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", {})

-- =============================================================================
-- Smart Splits
-- =============================================================================

local splits = require('smart-splits')

splits.setup()

-- recommended mappings
-- resizing splits
-- these keymaps will also accept a range,
-- for example `10<A-h>` will `resize_left` by `(10 * config.default_amount)`
vim.keymap.set('n', '<c-left>', splits.resize_left)
vim.keymap.set('n', '<c-down>', splits.resize_down)
vim.keymap.set('n', '<c-up>', splits.resize_up)
vim.keymap.set('n', '<c-right>', splits.resize_right)
-- moving between splits
vim.keymap.set('n', '<c-h>', splits.move_cursor_left)
vim.keymap.set('n', '<c-j>', splits.move_cursor_down)
vim.keymap.set('n', '<c-k>', splits.move_cursor_up)
vim.keymap.set('n', '<c-l>', splits.move_cursor_right)
vim.keymap.set('n', '<c-\\>', splits.move_cursor_previous)
-- swapping buffers between windows
vim.keymap.set('n', '<leader><leader>h', splits.swap_buf_left)
vim.keymap.set('n', '<leader><leader>j', splits.swap_buf_down)
vim.keymap.set('n', '<leader><leader>k', splits.swap_buf_up)
vim.keymap.set('n', '<leader><leader>l', splits.swap_buf_right)

-- =============================================================================
-- Pencil
-- =============================================================================

vim.api.nvim_create_autocmd({"FileType"}, {
  pattern = {"markdown", "text"},
  callback = function()
    vim.cmd("PencilSoft")
  end
})

-- =============================================================================
-- Avante
-- =============================================================================

local avante = require('avante')

avante.setup({
  provider = "openai",
})

vim.keymap.set('n', '<c-0>', function() require("avante.api").ask({ ask = false }) end, { noremap = true })

-- =============================================================================
-- Mason
-- =============================================================================

local mason = require('mason')

mason.setup({
})

-- =============================================================================
-- LSP
-- =============================================================================

-- For lazy loading see:
-- https://lsp-zero.netlify.app/v3.x/guide/lazy-loading-with-lazy-nvim.html

local lsp_zero = require('lsp-zero')

-- Enable keybindings only when you have a language server active in the current file.
lsp_zero.on_attach(function(client, bufnr)
  -- see :help lsp-zero-keybindings
  -- to learn the available actions
  lsp_zero.default_keymaps({buffer = bufnr})
end)

-- Setup language servers
local lspconfig = require('lspconfig')

-- Emmet
lspconfig.emmet_language_server.setup({})

-- Kotlin
lspconfig.kotlin_language_server.setup({})

-- TypeScript
-- lspconfig.tsserver.setup({})
lspconfig.ts_ls.setup({})

--------------------------------------------------------------------------------------
-- Start Ruby
--------------------------------------------------------------------------------------

-- textDocument/diagnostic support until 0.10.0 is released
_timers = {}
local function setup_diagnostics(client, buffer)
  if require("vim.lsp.diagnostic")._enable then
    return
  end

  local diagnostic_handler = function()
    local params = vim.lsp.util.make_text_document_params(buffer)
    client.request("textDocument/diagnostic", { textDocument = params }, function(err, result)
      if err then
        local err_msg = string.format("diagnostics error - %s", vim.inspect(err))
        vim.lsp.log.error(err_msg)
      end
      local diagnostic_items = {}
      if result then
        diagnostic_items = result.items
      end
      vim.lsp.diagnostic.on_publish_diagnostics(
        nil,
        vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }),
        { client_id = client.id }
      )
    end)
  end

  diagnostic_handler() -- to request diagnostics on buffer when first attaching

  vim.api.nvim_buf_attach(buffer, false, {
    on_lines = function()
      if _timers[buffer] then
        vim.fn.timer_stop(_timers[buffer])
      end
      _timers[buffer] = vim.fn.timer_start(200, diagnostic_handler)
    end,
    on_detach = function()
      if _timers[buffer] then
        vim.fn.timer_stop(_timers[buffer])
      end
    end,
  })
end

-- adds ShowRubyDeps command to show dependencies in the quickfix list.
-- add the `all` argument to show indirect dependencies as well
local function add_ruby_deps_command(client, bufnr)
  vim.api.nvim_buf_create_user_command(bufnr, "ShowRubyDeps",
                                        function(opts)

    local params = vim.lsp.util.make_text_document_params()
    local showAll = opts.args == "all"

    client.request("rubyLsp/workspace/dependencies", params,
                    function(error, result)
        if error then
            print("Error showing deps: " .. error)
            return
        end

        local qf_list = {}
        for _, item in ipairs(result) do
            if showAll or item.dependency then
                table.insert(qf_list, {
                    text = string.format("%s (%s) - %s",
                                          item.name,
                                          item.version,
                                          item.dependency),

                    filename = item.path
                })
            end
        end

        vim.fn.setqflist(qf_list)
        vim.cmd('copen')
    end, bufnr)
  end, {nargs = "?", complete = function()
    return {"all"}
  end})
end

lspconfig.ruby_lsp.setup({
  on_attach = function(client, buffer)
    setup_diagnostics(client, buffer)
    add_ruby_deps_command(client, buffer)
  end,
})

-- adds ShowRubyDeps command to show dependencies in the quickfix list.
-- add the `all` argument to show indirect dependencies as well
local function add_ruby_deps_command(client, bufnr)
  vim.api.nvim_buf_create_user_command(bufnr, "ShowRubyDeps",
                                        function(opts)

    local params = vim.lsp.util.make_text_document_params()

    local showAll = opts.args == "all"

    client.request("rubyLsp/workspace/dependencies", params,
                  function(error, result)
      if error then
        print("Error showing deps: " .. error)
        return
      end

      local qf_list = {}
      for _, item in ipairs(result) do
        if showAll or item.dependency then
            table.insert(qf_list, {
                text = string.format("%s (%s) - %s",
                                      item.name,
                                      item.version,
                                      item.dependency),

                filename = item.path
            })
        end
      end

      vim.fn.setqflist(qf_list)
      vim.cmd('copen')
    end, bufnr)
  end, {nargs = "?", complete = function()
      return {"all"}
  end})
end

require("lspconfig").ruby_lsp.setup({
  on_attach = function(client, buffer)
    setup_diagnostics(client, buffer)
    add_ruby_deps_command(client, buffer)
  end,
})

--------------------------------------------------------------------------------------
-- End Ruby
--------------------------------------------------------------------------------------

-- Completions
local cmp = require('cmp')

cmp.setup({

  -- Even if mapping isn't mapped to anything it's still required for
  -- the completions to work.
  mapping = cmp.mapping.preset.insert({
    -- `Enter` key to confirm completion
    ['<cr>'] = cmp.mapping.confirm({select = false}),

    -- Ctrl+Space to trigger completion menu
    -- ['<C-Space>'] = cmp.mapping.complete(),

  })
})

Expected behavior

Expected the changes to be applied and the foo.rb to look like the following:

def add(j, i)
  j + i
end

def minus(j, i)
  j - i
end

Environment

NVIM v0.10.1 Build type: Release LuaJIT 2.1.1720049189 OS: macOS 14.5

Repro

require('user.plugins')
require('user.config')
aarnphm commented 1 month ago

Hi, please provide a minimal config that only contains relevant info for avante.nvim.

Dumping your whole config won't help here.

matthewblott commented 1 month ago

Okay. I've tried a fresh install with a bare bones configuration and lazy.nvim installed at ${HOME}/.local/share/nvim/lazy.nvim. The result is the same. Here is the init.lua config in full:

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'

if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    'git',
    'clone',
    '--filter=blob:none',
    'https://github.com/folke/lazy.nvim.git',
    '--branch=stable', -- latest stable release
    lazypath,
  }
end

vim.opt.rtp:prepend(lazypath)

require('lazy').setup({
  {
    'yetone/avante.nvim',
    event = 'VeryLazy',
    lazy = false,
    version = false, 
    opts = {
      provider = "openai",
    },
    build = 'make BUILD_FROM_SOURCE=true',
    dependencies = {
      'stevearc/dressing.nvim',
      'nvim-lua/plenary.nvim',
      'MunifTanjim/nui.nvim',
      {
        'MeanderingProgrammer/render-markdown.nvim',
        opts = {
          file_types = { 'markdown', 'Avante' },
        },
        ft = { 'markdown', 'Avante' },
      },
    },
  },

}) 

vim.wo.number = true
vim.wo.relativenumber = true
vim.opt.expandtab = true
vim.opt.clipboard = 'unnamedplus'

vim.g.mapleader = ' '

I tried to keep everything to a minimum. I also tried the config as suggested on the homepage of this site.

ddillert commented 1 month ago

It looks like the following line in your config.lua might be causing the issue:

keymap('n', 'a', '$A', opts)

This remaps the a key to move the cursor to the end of the line ($) and enter insert mode (A). As a result, this likely overrides the default behavior of the a key, including within the sidebar.

To resolve this, try removing or modifying that key mapping.

matthewblott commented 1 month ago

@ddillert Nah, it's nothing to do with that although that's what I thought at first. If you look at my last reply I've given you the full init.lua file. I removed virtually everything.

ddillert commented 1 month ago

@matthewblott Could you please share the exact text output you're receiving from the model by posting it here?

matthewblott commented 1 month ago

Below is the full response to the following chat request:

Create a request test for the index method of the about controller.

Screenshot 2024-09-18 at 22 32 34

If I select the top line of each code snippet then the apply this option becomes available: Screenshot 2024-09-18 at 22 36 15

However I am not able to perform any action either by click on apply this or trying the keyboard shortcut.

ddillert commented 1 month ago

@matthewblott, thanks for the screenshots! I tested your example and ran into the same issue.

Could you please try using :AvanteAsk or <Leader>aa with the same request to see if the issue persists?

Currently, for the apply feature to work, we expect a spec'ed string with line numbers to appear before the code snippets. These line numbers guide where to insert the snippets in the open file, but in this case, both the line numbers and spec'ed strings are not present.

@aarnphm, it looks like lua/avante/templates/planning.avanterules only implements this for the :AvanteAsk feature.

Should we consider modifying the templates to include line numbers for :AvanteChat, disabling the apply feature when line numbers are missing, or improving pattern matching by appending everything to the end of the file in the absence of line numbers? One possible approach could be:

If no line numbers are present, detect the keywords Add, code, and the filename that matches the currently open file, then use the last line number from the open file's buffer to insert the snippet.

matthewblott commented 1 month ago

I tried AvanteAsk and this was the result:

Screenshot 2024-09-19 at 00 35 07

I then ran :set modifiable to see if that made a difference. The result was the same as it was when I ran AvanteChat.

yetone commented 1 month ago

Since avante started supporting avanterules (using jinja2 to render prompts), there has been a serious bug: due to an error in the template of the prompts, jinja2 incorrectly filtered out key information from the prompts, resulting in incorrect final generated prompts. This has caused issues with returned content not conforming to specifications recently. I fixed this serious bug yesterday: https://github.com/yetone/avante.nvim/pull/603. I suspect your issue might also be related to this bug. Could you update avante to the latest version and try again?

flopex commented 1 month ago

Having this exact same issue. I'm on latest version of avante image

yetone commented 1 month ago

@flopex Can you take a screenshot to show what your LLM response is?

flopex commented 1 month ago

I think I just figured out why, you first have to select one of response's code snippets before it can "<A: apply all".

Only getting the error if I try to <A from any of the response's text.

Since after submitting a request and cursor lands on the response pane, you kind of assume <A would be valid.

matthewblott commented 1 month ago

@flopex This was my experience too.

javeoff commented 1 month ago

I have the same problem with minimal configuration from readme. After pressing "a" does not happen

javeoff commented 1 month ago
return {
    "yetone/avante.nvim",
    event = "VeryLazy",
    lazy = false,
    version = false, -- set this if you want to always pull the latest change
    opts = {
        provider = "openai",
        auto_suggestions_provider = "openai",
        behaviour = {
            auto_suggestions = true, -- Experimental stage
            auto_set_highlight_group = true,
            auto_set_keymaps = true,
            auto_apply_diff_after_generation = false,
            support_paste_from_clipboard = false,
        },
        hints = { enabled = true },
        highlights = {
            ---@type AvanteConflictHighlights
            diff = {
                current = "DiffText",
                incoming = "DiffAdd",
            },
        },
        --- @class AvanteConflictUserConfig
        diff = {
            autojump = true,
            ---@type string | fun(): any
            list_opener = "copen",
        },
        mappings = {
            --- @class AvanteConflictMappings
            diff = {
                ours = "co",
                theirs = "ct",
                all_theirs = "ca",
                both = "cb",
                cursor = "cc",
                next = "]x",
                prev = "[x",
            },
            suggestion = {
                accept = "<M-l>",
                next = "<M-]>",
                prev = "<M-[>",
                dismiss = "<C-]>",
            },
            jump = {
                next = "§]",
                prev = "§[",
            },
            submit = {
                normal = "<CR>",
                insert = "<C-s>",
            },
            sidebar = {
                switch_windows = "<Tab>",
                reverse_switch_windows = "<S-Tab>",
            },
        },
    },
    keys = {
        { "§-", ":AvanteAsk<cr>", desc = "Avante" },
    },
    -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
    build = "make",
    -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
    dependencies = {
        "nvim-treesitter/nvim-treesitter",
        "stevearc/dressing.nvim",
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",
        --- The below dependencies are optional,
        "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
        "zbirenbaum/copilot.lua",    -- for providers='copilot'
        {
            -- support for image pasting
            "HakonHarnes/img-clip.nvim",
            event = "VeryLazy",
            opts = {
                -- recommended settings
                default = {
                    embed_image_as_base64 = false,
                    prompt_for_file_name = false,
                    drag_and_drop = {
                        insert_mode = true,
                    },
                    -- required for Windows users
                    use_absolute_path = true,
                },
            },
        },
        {
            -- Make sure to set this up properly if you have lazy=true
            'MeanderingProgrammer/render-markdown.nvim',
            opts = {
                file_types = { "markdown", "Avante" },
            },
            ft = { "markdown", "Avante" },
        },
    },
}
eyalk11 commented 2 weeks ago

I am having the same issue

jaydeland commented 2 weeks ago

Same

makermotion commented 1 week ago

I am having the same issue, any solutions available yet?

ryul99 commented 2 days ago

This is the way how I reproduced the error:

  1. use qwen2.5-coder:7b-instruct-q8_0 with ollama and foo.rb in the first issue message.
  2. type produce minus function several times in AvanteAsk until apply doesnt work

Apply works ->

image

Apply doesn't work ->

image

When I debugged this issue, there was empty filepath in selected_snippets_map of sidebar.lua https://github.com/yetone/avante.nvim/blob/main/lua/avante/sidebar.lua#L550-L557

image

I think emtpy (or wrong) filepath is the cause of this issue. filepath is set by the relative position of start_line_in_response_buf ( https://github.com/yetone/avante.nvim/blob/main/lua/avante/sidebar.lua#L365 ) and the error occurs when the LLM doesn't follow the prompts (like placing the file path in wrong position of response)

makermotion commented 2 hours ago

I am having the same issue, any solutions available yet?

applying changes work when I use avante ask not avante chat