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] middle-clicking to close programs on Linux pastes selection into open program #1046

Closed
laurensvalk opened this issue Apr 25, 2023 · 8 comments · Fixed by pybricks/pybricks-code#1717
Assignees
Labels
bug Something isn't working OS: Linux Issues that only occur on Linux software: pybricks-code Issues with https://code.pybricks.com application

Comments

@laurensvalk
Copy link
Member

Describe the bug
Occasionally, the script gets in a bad state. From what I can tell, several scripts got merged.

image

To reproduce
Haven't found a consistent approach. If I had to guess, this happens only when closing quite a few tabs fairly quickly. (Mouse on first one, repeatedly click middle button.)

@laurensvalk laurensvalk added bug Something isn't working software: pybricks-code Issues with https://code.pybricks.com application labels Apr 25, 2023
@dlech
Copy link
Member

dlech commented Apr 25, 2023

This looks like the same script repeated twice rather than two different scripts being merged. Does it also happen that two different scripts get concated like this?

@laurensvalk
Copy link
Member Author

Found it! Closing by middle-click has the side effect of paste-last-selection which is also done with middle click.

See demo below. So, depending on what was selected, this can feel like "multiple scripts merging" even if something else is happening.

For what it's worth, separate from this issue, my vote would be to disable paste-last-selection-by-middle-click altogether. I always disable in in VS Code too. It happens way too often accidentally while scrolling/moving.

update-2023-04-25_19.37.34.mp4

@dlech
Copy link
Member

dlech commented Apr 25, 2023

Nice find. I didn't even know that was a feature.

@dlech
Copy link
Member

dlech commented Apr 25, 2023

Where/how do you disable this in VS Code? Web searches tell me this is a Linux feature rather than a VS Code feature.

@laurensvalk
Copy link
Member Author

I think you're right. I must be confusing it with some other VSCode feature I have disabled.

@laurensvalk
Copy link
Member Author

laurensvalk commented Apr 25, 2023

FWIW, I found that other setting, and it is indeed somewhat related:

I set "editor.emptySelectionClipboard": false, so that CTRL+C with no selection doesn't copy the line.

Sometimes I accidentally press CTRL+C when I mean to paste. But by default the clipboard content is now overridden so you have to start over. I suppose my Pybricks Code scripts aren't that big so it hasn't been as much of a nuisance.

@dlech
Copy link
Member

dlech commented Apr 25, 2023

It looks like editor.selectionClipboard is the option. microsoft/vscode#14610 (comment)

Although that doesn't actually seem to fix the problem.

@dlech dlech changed the title [Bug] Pybricks Code scripts in a bad state [Bug] middle-clicking to close programs on Linux pastes selection into open program Apr 25, 2023
@dlech dlech added the OS: Linux Issues that only occur on Linux label Apr 25, 2023
@dlech dlech self-assigned this Apr 27, 2023
dlech added a commit to pybricks/pybricks-code that referenced this issue Apr 27, 2023
To avoid the Linux feature of pasting on middle click, we need to
consume the mouse up event in the browser on middle click instead of
mouse down.

This also sets the `selectionClipboard` editor option to false which
should disable the feature altogether in the monaco editor but the
setting seems to be broken in the browser[1].

[1]: microsoft/vscode#181050

Fixes: pybricks/support#1046
dlech added a commit to pybricks/pybricks-code that referenced this issue Apr 27, 2023
To avoid the Linux feature of pasting on middle click, we need to
consume the mouse up event in the browser on middle click instead of
mouse down.

This also sets the `selectionClipboard` editor option to false which
should disable the feature altogether in the monaco editor but the
setting seems to be broken in the browser[1].

[1]: microsoft/vscode#181050

Fixes: pybricks/support#1046
@dlech
Copy link
Member

dlech commented Apr 28, 2023

Although that doesn't actually seem to fix the problem.

microsoft/vscode#181050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working OS: Linux Issues that only occur on Linux software: pybricks-code Issues with https://code.pybricks.com application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants