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

Clicking past the end of a line triggers yank #2699

Closed
CptPotato opened this issue Jun 7, 2022 · 5 comments · Fixed by #2711
Closed

Clicking past the end of a line triggers yank #2699

CptPotato opened this issue Jun 7, 2022 · 5 comments · Fixed by #2711
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@CptPotato
Copy link
Contributor

CptPotato commented Jun 7, 2022

Summary

When clicking past the end of a line, helix yanks the text as if I clicked and dragged.

This also seems to happen when clicking other positions in the terminal, such as the gutter (although in that case the cursor position remains unchanged). I suspect that this happens whenever a click doesn't land on a character from the document.

Reproduction Steps

  • open helix
  • click anywhere on the first line or the status line
    • helix reports: yanked main selection to system clipboard

Helix log

Nothing helpful is logged

Platform

Windows

Terminal Emulator

wezterm, cmd, powershell

Helix Version

helix 22.05 (built from master 4a27e2d9)

@CptPotato CptPotato added the C-bug Category: This is a bug label Jun 7, 2022
@the-mikedavis
Copy link
Member

This may be windows-specific. I can't reproduce on wezterm on linux

@CptPotato
Copy link
Contributor Author

I'll try it on my linux machine later to confim.

@CptPotato
Copy link
Contributor Author

CptPotato commented Jun 7, 2022

Yup, seems to be Windows specific. I can't reproduce on Linux either (foot terminal). (incorrect, see below)

@the-mikedavis the-mikedavis added the O-windows Operating system: Windows label Jun 7, 2022
@CptPotato
Copy link
Contributor Author

CptPotato commented Jun 8, 2022

The behavior is a bit hard to describe; here's a quick visualization of what happens when clicking different areas:

  • #49a720 green: works as expected (moves the cursor but doesn't yank)
  • #a81d21 red: moves the cursor but also yanks
  • #a88e20 yellow: moves the cursor but doesn't yank (probably because it's past the end of the document)
  • #2084a8 blue: doesn't change the cursor position; yanks if the cursor is currently on a new line character (i.e. red area)

Edit: actually.. it looks like this is not a windows issue, but an issue with crlf line endings 😕
I guess crlf is interpreted as a two char selection, resulting in a yank.

@the-mikedavis the-mikedavis added A-helix-term Area: Helix term improvements and removed O-windows Operating system: Windows labels Jun 8, 2022
@the-mikedavis
Copy link
Member

I haven't tested it out yet but I bet it's this block:

MouseEvent {
kind: MouseEventKind::Up(MouseButton::Left),
..
} => {
if !config.middle_click_paste {
return EventResult::Ignored(None);
}
let (view, doc) = current!(cxt.editor);
let range = doc.selection(view.id).primary();
if range.to() - range.from() <= 1 {
return EventResult::Ignored(None);
}
commands::MappableCommand::yank_main_selection_to_primary_clipboard.execute(cxt);
EventResult::Consumed(None)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants