Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: apply/Apply all will accidentally create new folder named Here are the *SEARCH on not well formatted response. #1288

Closed
blindFS opened this issue Feb 17, 2025 · 7 comments · Fixed by #1315
Labels
bug Something isn't working

Comments

@blindFS
Copy link
Contributor

blindFS commented Feb 17, 2025

Describe the bug

Image

Also press a for apply on certain line will create new file named with code snippet

Image Image

To reproduce

I believe the key to reproduce the problem is the response itself, so I've just paste my response here:

Reponse
- Model: gemini/gemini-2.0-flash-001

- Selected files:
  - crates/nu-protocol/src/ast/operator.rs

> use strum crate to make the enums derive derive `EnumIter`

To add the `EnumIter` derive from the `strum` crate to the enums, we need to:

1.  Add `strum` as a dependency in `Cargo.toml`. Since I don't have access to that file, I'll skip this step and assume it's already done.
2.  Add `use strum_macros::EnumIter;` to the `operator.rs` file.
3.  Add `#[derive(EnumIter)]` to the `Comparison`, `Math`, `Boolean`, and `Bits` enums.

Here are the *SEARCH/REPLACE* blocks:

```text
Filepath: crates/nu-protocol/src/ast/operator.rs
Replace lines: 6-6
```rust
use super::{Expr, Expression};
use strum_macros::EnumIter;

Filepath: crates/nu-protocol/src/ast/operator.rs
Replace lines: 8-9

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
pub enum Comparison {

Filepath: crates/nu-protocol/src/ast/operator.rs
Replace lines: 26-27

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
pub enum Math {

Filepath: crates/nu-protocol/src/ast/operator.rs
Replace lines: 38-39

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
pub enum Boolean {

Filepath: crates/nu-protocol/src/ast/operator.rs
Replace lines: 45-46

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
pub enum Bits {

Expected behavior

No response

Installation method

Use lazy.nvim:

{
    "yetone/avante.nvim",
    event = "VeryLazy",
    version = false, -- set this if you want to always pull the latest change
    opts = {
      provider = "gemini",
      -- provider = "openrouter",
      gemini = {
        -- @see https://ai.google.dev/gemini-api/docs/models/gemini
        model = "gemini-2.0-flash-001",
        temperature = 0,
        max_tokens = 4096,
      },
    },
    -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
    build = "make",
    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
      {
        -- 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" },
      },
    },
  }

Environment

NVIM v0.10.4
Build type: Release
LuaJIT 2.1.1713773202

key val
kernel-name Darwin
kernel-release 24.3.0
kernel-version Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
machine arm64
operating-system Darwin

Repro

@blindFS blindFS added the bug Something isn't working label Feb 17, 2025
@yetone
Copy link
Owner

yetone commented Feb 17, 2025

‌‌‌Could you take a more complete screenshot? I want to see what the line above Replace lines is.

@blindFS
Copy link
Contributor Author

blindFS commented Feb 17, 2025

‌‌‌Could you take a more complete screenshot? I want to see what the line above Replace lines is.

They are all in the folded response

please check this:

Image

@blindFS
Copy link
Contributor Author

blindFS commented Feb 17, 2025

@yetone how about using tree-sitter-markdown to parse the diff blocks?

@yetone
Copy link
Owner

yetone commented Feb 20, 2025

‌It is recommended to use Cursor planning mode, as this issue will not exist in that mode:

https://github.com/yetone/avante.nvim/blob/main/cursor-planning-mode.md

@blindFS
Copy link
Contributor Author

blindFS commented Feb 20, 2025

‌It is recommended to use Cursor planning mode, as this issue will not exist in that mode:

https://github.com/yetone/avante.nvim/blob/main/cursor-planning-mode.md

I tried to turn on the planning behavior, but with the cached response, this issue persists. Do I need to call AvanteClear to test it? I'm afraid I won't be able to stably reproduce this issue on my setup if I do so.

Moreover, with planning behavior + my tree-sitter-markdown patch + cached response, I get a new error:

E5108: Error executing lua: ...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:335: attempt to concatenate local 'k' (a nil value)
stack traceback:
	...hare/nvim/lazy/avante.nvim/lua/avante/providers/init.lua:335: in function '__index'
	...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:901: in function 'apply'
	...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1379: in function <...local/share/nvim/lazy/avante.nvim/lua/avante/sidebar.lua:1379>

@yetone
Copy link
Owner

yetone commented Feb 20, 2025

‌‌After switching modes, do not use the response from the history; generate a new response.

@blindFS
Copy link
Contributor Author

blindFS commented Feb 20, 2025

‌‌After switching modes, do not use the response from the history; generate a new response.

I can't tell if it's fixed then, as I can't create the exact response once again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants