Merge pull request #1712 from zed-industries/dont-select-on-copy-by-default-terminal

Don't select on copy by default in the terminal
This commit is contained in:
Julia 2022-10-10 14:15:20 -04:00 committed by GitHub
commit 7d6690335f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 11 deletions

View file

@ -1071,7 +1071,18 @@ impl Terminal {
}
}
pub fn mouse_up(&mut self, e: &UpRegionEvent, origin: Vector2F) {
pub fn mouse_up(&mut self, e: &UpRegionEvent, origin: Vector2F, cx: &mut ModelContext<Self>) {
let settings = cx.global::<Settings>();
let copy_on_select = settings
.terminal_overrides
.copy_on_select
.unwrap_or_else(|| {
settings
.terminal_defaults
.copy_on_select
.expect("Should be set in defaults")
});
let position = e.position.sub(origin);
if self.mouse_mode(e.shift) {
let point = grid_point(
@ -1083,11 +1094,10 @@ impl Terminal {
if let Some(bytes) = mouse_button_report(point, e, false, self.last_content.mode) {
self.pty_tx.notify(bytes);
}
} else if e.button == MouseButton::Left {
// Seems pretty standard to automatically copy on mouse_up for terminals,
// so let's do that here
} else if e.button == MouseButton::Left && copy_on_select {
self.copy();
}
self.selection_phase = SelectionPhase::Ended;
self.last_mouse = None;
}

View file

@ -424,8 +424,8 @@ impl TerminalElement {
TerminalElement::generic_button_handler(
connection,
origin,
move |terminal, origin, e, _cx| {
terminal.mouse_up(&e, origin);
move |terminal, origin, e, cx| {
terminal.mouse_up(&e, origin, cx);
},
),
)
@ -492,8 +492,8 @@ impl TerminalElement {
TerminalElement::generic_button_handler(
connection,
origin,
move |terminal, origin, e, _cx| {
terminal.mouse_up(&e, origin);
move |terminal, origin, e, cx| {
terminal.mouse_up(&e, origin, cx);
},
),
)
@ -502,8 +502,8 @@ impl TerminalElement {
TerminalElement::generic_button_handler(
connection,
origin,
move |terminal, origin, e, _cx| {
terminal.mouse_up(&e, origin);
move |terminal, origin, e, cx| {
terminal.mouse_up(&e, origin, cx);
},
),
)