continue icon indicating copy to clipboard operation
continue copied to clipboard

Copying lines of code from chat into Jupyter Notebook duplicates code from cell

Open Mekcyed opened this issue 2 years ago • 17 comments

Describe the bug Copying lines of code from chat into Jupyter Notebook duplicates code from current cell

To Reproduce Steps to reproduce the behavior:

  1. Open Jupyter Notebook
  2. Write Code in a cell
  3. Let Continue generate some code in in the Chat
  4. Try to copy lines of code using CTRL+C from the Chat into the Jupyter Cell with CTRL + V

Expected behavior The selected Code should be copied from the chat.

Screenshots grafik

Environment

  • Operating System: Windws + WSL running a Python Dev Container
  • Continue v0.0.344

Console logs When pressing CTRL + V grafik

Additional context When Pasting in a simple text file the Copying works as expected.

Mekcyed avatar Aug 28 '23 11:08 Mekcyed

fascinating...

Copying from Continue and pasting into non-ipynb files works fine?

sestinj avatar Aug 28 '23 17:08 sestinj

I tested it only with a simple text file. There it worked as intended :D

Mekcyed avatar Aug 28 '23 17:08 Mekcyed

I've not gotten a double paste, but instead was completely unable to even copy from Continue (or any other side bar for that matter) while an .ipynb file was open. It seems like this is a VS Code issue, as there seems to be a whole trail of issues starting here related to copy/paste in python notebooks.

Is there anything in your keyboard shortcuts that might be relevant here? If you cmd+shift+p, "Keyboard Shortcuts", then search for "Notebook: " or maybe for "cmd+v", I'm wondering if there's a conflicting shortcut that only happens when notebooks are open.

sestinj avatar Aug 29 '23 04:08 sestinj

I guess it is more a "ctrl+c" problem. As long VSCode is in focus the last selected Cell in Jupyter is copied, even when text in e.g. Continue is selected.

My Shortcuts: image

So workaround for now would be to press the copy button in code sections in the chat -> paste to notebook cell -> delete unwanted stuff.

Mekcyed avatar Aug 29 '23 14:08 Mekcyed

Ok, what I can probably do is override ctrl+c within the webview's javascript to grab window.getSelection().toString() and throw that inside the copy buffer. I'll have to be sure there are no weird side-effects, but would expect it to work

sestinj avatar Aug 30 '23 00:08 sestinj

@Mekcyed Crazy enough this worked like a charm at least for me.

Just waiting 100ms and then filling in the copy buffer. New version is ready, 0.0.352.

I think I was having a slightly different issue than you though, so let me know if not fixed

sestinj avatar Aug 30 '23 02:08 sestinj

Thanks @sestinj ! But problem is still occurring :( I searched again in the settings and deactivated everything that sounded like jupyter notebook but it didnt help either. Any idea what might be the problem with the settings? image

Mekcyed avatar Aug 30 '23 08:08 Mekcyed

Mm I'm missing the keyboard event on windows 🤦🏻‍♂️ https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/ctrlKey

Was using just metaKey. Will change this in the morning and see if it solves things.

sestinj avatar Aug 30 '23 08:08 sestinj

@Mekcyed Just made the change, new version (v0.0.352) will be out within the hour. Let me know how this goes.

sestinj avatar Aug 31 '23 06:08 sestinj

It works like a charm 💯 Thank you for your time and work. Looking forward to see how continue develops further.

Mekcyed avatar Aug 31 '23 13:08 Mekcyed

Hey this issue is back in Version v0.0.412

Mekcyed avatar Oct 13 '23 14:10 Mekcyed

@Mekcyed I took a look to make sure and the solution that we implemented to fix this is still present, but I'm noticing that it might also have been necessary for you to disable all of the shortcuts like you did for it to work. Could you give a second look to the keyboard shortcut settings and see if anything new has shown up / try disabling them like you did before and let me know if this solves it?

sestinj avatar Oct 13 '23 17:10 sestinj

Hey, sorry for my short comment. I was in a bit of a hurry...

Copying from continue to jupyter notebook is still working... My bad. But vis a vis not. I can copy from the notebook but cant paste into continue (i do it because the ctrl+m command for adding lines to the context is not working in a notebook either). Then i get also the code pasted in the notebook again like in my original description of the bug and nothing lands in the chat.

Mekcyed avatar Oct 13 '23 19:10 Mekcyed

ok no worries, this makes a bit more sense : ) Let me first see if I can get ctrl+m working in the notebook, since this would be the ideal solution

Can you paste into other places I would assume, just not Continue?

sestinj avatar Oct 13 '23 19:10 sestinj

Nice! Yes i can paste everywhere else. Copilot Chat for example also.

Mekcyed avatar Oct 13 '23 19:10 Mekcyed

Doing some testing (and made sure that the behavior is same on both mac and windows). What I'm seeing is that ctrl+M successfully adds the range as context to Continue, but I notice that highlighting a second range is often problematic, since the line numbers of each cell start at zero, causing apparent overlap. But it sounds like you were unable to ctrl+M even when nothing was already selected in Continue?

sestinj avatar Oct 13 '23 19:10 sestinj

Same issue here, when editing .ipynb files I can highlight the codes but not able to copy the codes into the side window, it will only copy the exact code cell again and nothing happens in the side window

WeskerC avatar Feb 25 '24 08:02 WeskerC

I've just fixed this issue here and it is available in version 0.9.124

sestinj avatar May 02 '24 21:05 sestinj