Use lines and columns from the file url strings
This commit is contained in:
parent
82a9d53c8a
commit
94358ffb16
1 changed files with 38 additions and 8 deletions
|
@ -3,8 +3,10 @@ pub mod terminal_element;
|
||||||
pub mod terminal_panel;
|
pub mod terminal_panel;
|
||||||
|
|
||||||
use crate::{persistence::TERMINAL_DB, terminal_element::TerminalElement};
|
use crate::{persistence::TERMINAL_DB, terminal_element::TerminalElement};
|
||||||
|
use anyhow::Context;
|
||||||
use context_menu::{ContextMenu, ContextMenuItem};
|
use context_menu::{ContextMenu, ContextMenuItem};
|
||||||
use dirs::home_dir;
|
use dirs::home_dir;
|
||||||
|
use editor::{scroll::autoscroll::Autoscroll, Editor};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
elements::{AnchorCorner, ChildView, Flex, Label, ParentElement, Stack},
|
elements::{AnchorCorner, ChildView, Flex, Label, ParentElement, Stack},
|
||||||
|
@ -15,6 +17,7 @@ use gpui::{
|
||||||
AnyElement, AnyViewHandle, AppContext, Element, Entity, ModelHandle, Task, View, ViewContext,
|
AnyElement, AnyViewHandle, AppContext, Element, Entity, ModelHandle, Task, View, ViewContext,
|
||||||
ViewHandle, WeakViewHandle,
|
ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
|
use language::Bias;
|
||||||
use project::{LocalWorktree, Project};
|
use project::{LocalWorktree, Project};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
@ -177,16 +180,43 @@ impl TerminalView {
|
||||||
Event::OpenPath(maybe_path) => {
|
Event::OpenPath(maybe_path) => {
|
||||||
let potential_abs_paths = possible_open_targets(&workspace, maybe_path, cx);
|
let potential_abs_paths = possible_open_targets(&workspace, maybe_path, cx);
|
||||||
if let Some(path) = potential_abs_paths.into_iter().next() {
|
if let Some(path) = potential_abs_paths.into_iter().next() {
|
||||||
// TODO kb change selections using path_like row & column
|
|
||||||
let visible = path.path_like.is_dir();
|
let visible = path.path_like.is_dir();
|
||||||
if let Some(workspace) = workspace.upgrade(cx) {
|
let task_workspace = workspace.clone();
|
||||||
workspace.update(cx, |workspace, cx| {
|
cx.spawn(|_, mut cx| async move {
|
||||||
workspace
|
let opened_item = task_workspace
|
||||||
.open_abs_path(path.path_like, visible, cx)
|
.update(&mut cx, |workspace, cx| {
|
||||||
.detach_and_log_err(cx);
|
workspace.open_abs_path(path.path_like, visible, cx)
|
||||||
});
|
})
|
||||||
|
.context("workspace update")?
|
||||||
|
.await
|
||||||
|
.context("workspace update")?;
|
||||||
|
if let Some(row) = path.row {
|
||||||
|
let col = path.column.unwrap_or(0);
|
||||||
|
if let Some(active_editor) = opened_item.downcast::<Editor>() {
|
||||||
|
active_editor
|
||||||
|
.downgrade()
|
||||||
|
.update(&mut cx, |editor, cx| {
|
||||||
|
let snapshot = editor.snapshot(cx).display_snapshot;
|
||||||
|
let point = snapshot.buffer_snapshot.clip_point(
|
||||||
|
language::Point::new(
|
||||||
|
row.saturating_sub(1),
|
||||||
|
col.saturating_sub(1),
|
||||||
|
),
|
||||||
|
Bias::Left,
|
||||||
|
);
|
||||||
|
editor.change_selections(
|
||||||
|
Some(Autoscroll::center()),
|
||||||
|
cx,
|
||||||
|
|s| s.select_ranges([point..point]),
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.log_err();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
anyhow::Ok(())
|
||||||
|
})
|
||||||
|
.detach_and_log_err(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => cx.emit(event.clone()),
|
_ => cx.emit(event.clone()),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue