continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
14.38k stars 1.05k forks source link

Overwrites Previous Function when use continue in option #991

Open Chhunneng opened 5 months ago

Chhunneng commented 5 months ago

Before submitting your bug report

Relevant environment info

- OS: macOS 14.2.1
- Continue: v0.9.90
- IDE: VSCode 1.87.1

Description

When I use continue to edit like write a docstring for this code it works. but when finished I try to select the new function and use the same feature to write a docstring for this code again, it writes on the old function again.

To reproduce

I try to use continue and it work

Screenshot 2024-03-19 at 17 02 16 Screenshot 2024-03-19 at 17 06 42

After that, I try on new function but it back to old function

Screenshot 2024-03-19 at 17 07 31 Screenshot 2024-03-19 at 17 07 59

Log output

No response

TheLapinMalin commented 4 months ago

Bumping this, as I've had this issue as well with Ctrl+I:

Ctrl+I without selecting code seems to write code in other places (if you've used Ctrl+I once in the file somewhere, then move somewhere else and use Ctrl+I again, it generates code at the first Ctrl+I location again).

justinmilner1 commented 4 months ago

I was able to replicate this - I'll add that the issue only occurs if you don't accept or reject the suggested diff, and only within the same file.

It does seem to generate a new docstring for the newly highlighted function, but it annotates the previously targeted function.

1) Generate docstring for function 1 2) Don’t accept or reject 3) generate another docstring for function 2 4) See that newly generated docstring is describing function 2, but is annotated upon function 1

I'll look into this!

justinmilner1 commented 4 months ago

Looks like verticalDiffs are not being updated when lines are added/removed from the file. I think the best approach will be to create a listener for changes to the document (onDidChangeTextDocument) and if the change includes a line addition or deletion, make the appropriate changes to the diffhandler instance.

@sestinj Hey Nate - Two questions: 1) It looks like there is a 1:1 mapping of filepath to diffhandler in manager.ts, which means there can only be one vertical diff per file - is this intended functionality medium/long term? 2) If the user has a diff open in a file, and decides to create a new diff in the same file without closing the existing one, should we delete the existing diff? (leaning toward this option) Or prevent the new diff from being created? (and maybe send some type of notification that there is another diff waiting to be accepted/rejected)

sestinj commented 4 months ago

@justinmilner1 thanks for looking into this. 1:1 is intended for now. There's a of offsetting to keep track of if there are multiple diffs being generated in a single file, and especially if the user tries to generate over top of an existing one there's really not a great UI solution. So unless it turns out to be a majorly requested feature the plan was to keep up a guide rail.

I agree with your take about deleting the old one