mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 04:43:17 +03:00
Merge pull request #1765 from zed-industries/fix-terminal-hyperlinks
Open hyperlinks on up, not down, and disable them when dragging.
This commit is contained in:
commit
318b923bac
@ -1018,33 +1018,13 @@ impl Terminal {
|
|||||||
self.last_content.size,
|
self.last_content.size,
|
||||||
self.last_content.display_offset,
|
self.last_content.display_offset,
|
||||||
);
|
);
|
||||||
// let side = mouse_side(position, self.last_content.size);
|
|
||||||
|
|
||||||
if self.mouse_mode(e.shift) {
|
if self.mouse_mode(e.shift) {
|
||||||
if let Some(bytes) = mouse_button_report(point, e, true, self.last_content.mode) {
|
if let Some(bytes) = mouse_button_report(point, e, true, self.last_content.mode) {
|
||||||
self.pty_tx.notify(bytes);
|
self.pty_tx.notify(bytes);
|
||||||
}
|
}
|
||||||
} else if e.button == MouseButton::Left {
|
} else if e.button == MouseButton::Left {
|
||||||
self.left_click(e, origin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn left_click(&mut self, e: &DownRegionEvent, origin: Vector2F) {
|
|
||||||
let position = e.position.sub(origin);
|
let position = e.position.sub(origin);
|
||||||
if !self.mouse_mode(e.shift) {
|
|
||||||
//Hyperlinks
|
|
||||||
{
|
|
||||||
let mouse_cell_index = content_index_for_mouse(position, &self.last_content);
|
|
||||||
if let Some(link) = self.last_content.cells[mouse_cell_index].hyperlink() {
|
|
||||||
open_uri(link.uri()).log_err();
|
|
||||||
} else {
|
|
||||||
self.events
|
|
||||||
.push_back(InternalEvent::FindHyperlink(position, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Selections
|
|
||||||
{
|
|
||||||
let point = grid_point(
|
let point = grid_point(
|
||||||
position,
|
position,
|
||||||
self.last_content.size,
|
self.last_content.size,
|
||||||
@ -1060,8 +1040,8 @@ impl Terminal {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let selection = selection_type
|
let selection =
|
||||||
.map(|selection_type| Selection::new(selection_type, point, side));
|
selection_type.map(|selection_type| Selection::new(selection_type, point, side));
|
||||||
|
|
||||||
if let Some(sel) = selection {
|
if let Some(sel) = selection {
|
||||||
self.events
|
self.events
|
||||||
@ -1069,7 +1049,6 @@ impl Terminal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn mouse_up(&mut self, e: &UpRegionEvent, origin: Vector2F, cx: &mut ModelContext<Self>) {
|
pub fn mouse_up(&mut self, e: &UpRegionEvent, origin: Vector2F, cx: &mut ModelContext<Self>) {
|
||||||
let settings = cx.global::<Settings>();
|
let settings = cx.global::<Settings>();
|
||||||
@ -1094,10 +1073,23 @@ impl Terminal {
|
|||||||
if let Some(bytes) = mouse_button_report(point, e, false, self.last_content.mode) {
|
if let Some(bytes) = mouse_button_report(point, e, false, self.last_content.mode) {
|
||||||
self.pty_tx.notify(bytes);
|
self.pty_tx.notify(bytes);
|
||||||
}
|
}
|
||||||
} else if e.button == MouseButton::Left && copy_on_select {
|
} else {
|
||||||
|
if e.button == MouseButton::Left && copy_on_select {
|
||||||
self.copy();
|
self.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Hyperlinks
|
||||||
|
if self.selection_phase == SelectionPhase::Ended {
|
||||||
|
let mouse_cell_index = content_index_for_mouse(position, &self.last_content);
|
||||||
|
if let Some(link) = self.last_content.cells[mouse_cell_index].hyperlink() {
|
||||||
|
open_uri(link.uri()).log_err();
|
||||||
|
} else {
|
||||||
|
self.events
|
||||||
|
.push_back(InternalEvent::FindHyperlink(position, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.selection_phase = SelectionPhase::Ended;
|
self.selection_phase = SelectionPhase::Ended;
|
||||||
self.last_mouse = None;
|
self.last_mouse = None;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user