Remove more todos
This commit is contained in:
parent
feaab953a8
commit
3e8fcefaef
6 changed files with 910 additions and 915 deletions
File diff suppressed because it is too large
Load diff
|
@ -7,8 +7,9 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
point, AnyElement, AppContext, AsyncAppContext, Entity, EntityId, FocusHandle, Model, Pixels,
|
div, point, AnyElement, AppContext, AsyncAppContext, Entity, EntityId, FocusHandle, Model,
|
||||||
SharedString, Subscription, Task, View, ViewContext, VisualContext, WeakView,
|
ParentElement, Pixels, SharedString, Styled, Subscription, Task, View, ViewContext,
|
||||||
|
VisualContext, WeakView,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
||||||
|
@ -26,7 +27,7 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use text::Selection;
|
use text::Selection;
|
||||||
use theme::ThemeVariant;
|
use theme::{ActiveTheme, ThemeVariant};
|
||||||
use util::{paths::PathExt, ResultExt, TryFutureExt};
|
use util::{paths::PathExt, ResultExt, TryFutureExt};
|
||||||
use workspace::item::{BreadcrumbText, FollowableItemHandle};
|
use workspace::item::{BreadcrumbText, FollowableItemHandle};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
|
@ -576,25 +577,21 @@ impl Item for Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tab_content<T: 'static>(&self, detail: Option<usize>, cx: &AppContext) -> AnyElement<T> {
|
fn tab_content<T: 'static>(&self, detail: Option<usize>, cx: &AppContext) -> AnyElement<T> {
|
||||||
AnyElement::new(gpui::ParentElement::child(gpui::div(), "HEY"))
|
let theme = cx.theme();
|
||||||
|
AnyElement::new(
|
||||||
// Flex::row()
|
div()
|
||||||
// .with_child(Label::new(self.title(cx).to_string(), style.label.clone()).into_any())
|
.flex()
|
||||||
// .with_children(detail.and_then(|detail| {
|
.flex_row()
|
||||||
// let path = path_for_buffer(&self.buffer, detail, false, cx)?;
|
.items_center()
|
||||||
// let description = path.to_string_lossy();
|
.bg(gpui::white())
|
||||||
// Some(
|
.text_color(gpui::white())
|
||||||
// Label::new(
|
.child(self.title(cx).to_string())
|
||||||
// util::truncate_and_trailoff(&description, MAX_TAB_TITLE_LEN),
|
.children(detail.and_then(|detail| {
|
||||||
// style.description.text.clone(),
|
let path = path_for_buffer(&self.buffer, detail, false, cx)?;
|
||||||
// )
|
let description = path.to_string_lossy();
|
||||||
// .contained()
|
Some(util::truncate_and_trailoff(&description, MAX_TAB_TITLE_LEN))
|
||||||
// .with_style(style.description.container)
|
})),
|
||||||
// .aligned(),
|
)
|
||||||
// )
|
|
||||||
// }))
|
|
||||||
// .align_children_center()
|
|
||||||
// .into_any()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_each_project_item(
|
fn for_each_project_item(
|
||||||
|
|
|
@ -2,7 +2,8 @@ use crate::{
|
||||||
display_map::DisplaySnapshot,
|
display_map::DisplaySnapshot,
|
||||||
element::PointForPosition,
|
element::PointForPosition,
|
||||||
hover_popover::{self, InlayHover},
|
hover_popover::{self, InlayHover},
|
||||||
Anchor, DisplayPoint, Editor, EditorSnapshot, InlayId, SelectPhase,
|
Anchor, DisplayPoint, Editor, EditorSnapshot, GoToDefinition, GoToTypeDefinition, InlayId,
|
||||||
|
SelectPhase,
|
||||||
};
|
};
|
||||||
use gpui::{Task, ViewContext};
|
use gpui::{Task, ViewContext};
|
||||||
use language::{Bias, ToOffset};
|
use language::{Bias, ToOffset};
|
||||||
|
@ -108,61 +109,59 @@ pub fn update_go_to_definition_link(
|
||||||
shift_held: bool,
|
shift_held: bool,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
todo!("old version below");
|
let pending_nonempty_selection = editor.has_pending_nonempty_selection();
|
||||||
|
|
||||||
|
// Store new mouse point as an anchor
|
||||||
|
let snapshot = editor.snapshot(cx);
|
||||||
|
let trigger_point = match origin {
|
||||||
|
Some(GoToDefinitionTrigger::Text(p)) => {
|
||||||
|
Some(TriggerPoint::Text(snapshot.buffer_snapshot.anchor_before(
|
||||||
|
p.to_offset(&snapshot.display_snapshot, Bias::Left),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
Some(GoToDefinitionTrigger::InlayHint(p, lsp_location, language_server_id)) => {
|
||||||
|
Some(TriggerPoint::InlayHint(p, lsp_location, language_server_id))
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
// If the new point is the same as the previously stored one, return early
|
||||||
|
if let (Some(a), Some(b)) = (
|
||||||
|
&trigger_point,
|
||||||
|
&editor.link_go_to_definition_state.last_trigger_point,
|
||||||
|
) {
|
||||||
|
match (a, b) {
|
||||||
|
(TriggerPoint::Text(anchor_a), TriggerPoint::Text(anchor_b)) => {
|
||||||
|
if anchor_a.cmp(anchor_b, &snapshot.buffer_snapshot).is_eq() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(TriggerPoint::InlayHint(range_a, _, _), TriggerPoint::InlayHint(range_b, _, _)) => {
|
||||||
|
if range_a == range_b {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.link_go_to_definition_state.last_trigger_point = trigger_point.clone();
|
||||||
|
|
||||||
|
if pending_nonempty_selection {
|
||||||
|
hide_link_definition(editor, cx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if cmd_held {
|
||||||
|
if let Some(trigger_point) = trigger_point {
|
||||||
|
let kind = trigger_point.definition_kind(shift_held);
|
||||||
|
show_link_definition(kind, editor, trigger_point, snapshot, cx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hide_link_definition(editor, cx);
|
||||||
}
|
}
|
||||||
// let pending_nonempty_selection = editor.has_pending_nonempty_selection();
|
|
||||||
|
|
||||||
// // Store new mouse point as an anchor
|
|
||||||
// let snapshot = editor.snapshot(cx);
|
|
||||||
// let trigger_point = match origin {
|
|
||||||
// Some(GoToDefinitionTrigger::Text(p)) => {
|
|
||||||
// Some(TriggerPoint::Text(snapshot.buffer_snapshot.anchor_before(
|
|
||||||
// p.to_offset(&snapshot.display_snapshot, Bias::Left),
|
|
||||||
// )))
|
|
||||||
// }
|
|
||||||
// Some(GoToDefinitionTrigger::InlayHint(p, lsp_location, language_server_id)) => {
|
|
||||||
// Some(TriggerPoint::InlayHint(p, lsp_location, language_server_id))
|
|
||||||
// }
|
|
||||||
// None => None,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // If the new point is the same as the previously stored one, return early
|
|
||||||
// if let (Some(a), Some(b)) = (
|
|
||||||
// &trigger_point,
|
|
||||||
// &editor.link_go_to_definition_state.last_trigger_point,
|
|
||||||
// ) {
|
|
||||||
// match (a, b) {
|
|
||||||
// (TriggerPoint::Text(anchor_a), TriggerPoint::Text(anchor_b)) => {
|
|
||||||
// if anchor_a.cmp(anchor_b, &snapshot.buffer_snapshot).is_eq() {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// (TriggerPoint::InlayHint(range_a, _, _), TriggerPoint::InlayHint(range_b, _, _)) => {
|
|
||||||
// if range_a == range_b {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// _ => {}
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// editor.link_go_to_definition_state.last_trigger_point = trigger_point.clone();
|
|
||||||
|
|
||||||
// if pending_nonempty_selection {
|
|
||||||
// hide_link_definition(editor, cx);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if cmd_held {
|
|
||||||
// if let Some(trigger_point) = trigger_point {
|
|
||||||
// let kind = trigger_point.definition_kind(shift_held);
|
|
||||||
// show_link_definition(kind, editor, trigger_point, snapshot, cx);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// hide_link_definition(editor, cx);
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn update_inlay_link_and_hover_points(
|
pub fn update_inlay_link_and_hover_points(
|
||||||
snapshot: &DisplaySnapshot,
|
snapshot: &DisplaySnapshot,
|
||||||
|
@ -353,204 +352,202 @@ pub fn show_link_definition(
|
||||||
snapshot: EditorSnapshot,
|
snapshot: EditorSnapshot,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
todo!("old implementation below")
|
let same_kind = editor.link_go_to_definition_state.kind == Some(definition_kind);
|
||||||
|
if !same_kind {
|
||||||
|
hide_link_definition(editor, cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if editor.pending_rename.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let trigger_anchor = trigger_point.anchor();
|
||||||
|
let (buffer, buffer_position) = if let Some(output) = editor
|
||||||
|
.buffer
|
||||||
|
.read(cx)
|
||||||
|
.text_anchor_for_position(trigger_anchor.clone(), cx)
|
||||||
|
{
|
||||||
|
output
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let excerpt_id = if let Some((excerpt_id, _, _)) = editor
|
||||||
|
.buffer()
|
||||||
|
.read(cx)
|
||||||
|
.excerpt_containing(trigger_anchor.clone(), cx)
|
||||||
|
{
|
||||||
|
excerpt_id
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let project = if let Some(project) = editor.project.clone() {
|
||||||
|
project
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Don't request again if the location is within the symbol region of a previous request with the same kind
|
||||||
|
if let Some(symbol_range) = &editor.link_go_to_definition_state.symbol_range {
|
||||||
|
if same_kind && symbol_range.point_within_range(&trigger_point, &snapshot) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let task = cx.spawn(|this, mut cx| {
|
||||||
|
async move {
|
||||||
|
let result = match &trigger_point {
|
||||||
|
TriggerPoint::Text(_) => {
|
||||||
|
// query the LSP for definition info
|
||||||
|
project
|
||||||
|
.update(&mut cx, |project, cx| match definition_kind {
|
||||||
|
LinkDefinitionKind::Symbol => {
|
||||||
|
project.definition(&buffer, buffer_position, cx)
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkDefinitionKind::Type => {
|
||||||
|
project.type_definition(&buffer, buffer_position, cx)
|
||||||
|
}
|
||||||
|
})?
|
||||||
|
.await
|
||||||
|
.ok()
|
||||||
|
.map(|definition_result| {
|
||||||
|
(
|
||||||
|
definition_result.iter().find_map(|link| {
|
||||||
|
link.origin.as_ref().map(|origin| {
|
||||||
|
let start = snapshot.buffer_snapshot.anchor_in_excerpt(
|
||||||
|
excerpt_id.clone(),
|
||||||
|
origin.range.start,
|
||||||
|
);
|
||||||
|
let end = snapshot.buffer_snapshot.anchor_in_excerpt(
|
||||||
|
excerpt_id.clone(),
|
||||||
|
origin.range.end,
|
||||||
|
);
|
||||||
|
RangeInEditor::Text(start..end)
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
definition_result
|
||||||
|
.into_iter()
|
||||||
|
.map(GoToDefinitionLink::Text)
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
TriggerPoint::InlayHint(highlight, lsp_location, server_id) => Some((
|
||||||
|
Some(RangeInEditor::Inlay(highlight.clone())),
|
||||||
|
vec![GoToDefinitionLink::InlayHint(
|
||||||
|
lsp_location.clone(),
|
||||||
|
*server_id,
|
||||||
|
)],
|
||||||
|
)),
|
||||||
|
};
|
||||||
|
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
// Clear any existing highlights
|
||||||
|
this.clear_highlights::<LinkGoToDefinitionState>(cx);
|
||||||
|
this.link_go_to_definition_state.kind = Some(definition_kind);
|
||||||
|
this.link_go_to_definition_state.symbol_range = result
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|(symbol_range, _)| symbol_range.clone());
|
||||||
|
|
||||||
|
if let Some((symbol_range, definitions)) = result {
|
||||||
|
this.link_go_to_definition_state.definitions = definitions.clone();
|
||||||
|
|
||||||
|
let buffer_snapshot = buffer.read(cx).snapshot();
|
||||||
|
|
||||||
|
// Only show highlight if there exists a definition to jump to that doesn't contain
|
||||||
|
// the current location.
|
||||||
|
let any_definition_does_not_contain_current_location =
|
||||||
|
definitions.iter().any(|definition| {
|
||||||
|
match &definition {
|
||||||
|
GoToDefinitionLink::Text(link) => {
|
||||||
|
if link.target.buffer == buffer {
|
||||||
|
let range = &link.target.range;
|
||||||
|
// Expand range by one character as lsp definition ranges include positions adjacent
|
||||||
|
// but not contained by the symbol range
|
||||||
|
let start = buffer_snapshot.clip_offset(
|
||||||
|
range
|
||||||
|
.start
|
||||||
|
.to_offset(&buffer_snapshot)
|
||||||
|
.saturating_sub(1),
|
||||||
|
Bias::Left,
|
||||||
|
);
|
||||||
|
let end = buffer_snapshot.clip_offset(
|
||||||
|
range.end.to_offset(&buffer_snapshot) + 1,
|
||||||
|
Bias::Right,
|
||||||
|
);
|
||||||
|
let offset = buffer_position.to_offset(&buffer_snapshot);
|
||||||
|
!(start <= offset && end >= offset)
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GoToDefinitionLink::InlayHint(_, _) => true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if any_definition_does_not_contain_current_location {
|
||||||
|
// todo!()
|
||||||
|
// // Highlight symbol using theme link definition highlight style
|
||||||
|
// let style = theme::current(cx).editor.link_definition;
|
||||||
|
// let highlight_range =
|
||||||
|
// symbol_range.unwrap_or_else(|| match &trigger_point {
|
||||||
|
// TriggerPoint::Text(trigger_anchor) => {
|
||||||
|
// let snapshot = &snapshot.buffer_snapshot;
|
||||||
|
// // If no symbol range returned from language server, use the surrounding word.
|
||||||
|
// let (offset_range, _) =
|
||||||
|
// snapshot.surrounding_word(*trigger_anchor);
|
||||||
|
// RangeInEditor::Text(
|
||||||
|
// snapshot.anchor_before(offset_range.start)
|
||||||
|
// ..snapshot.anchor_after(offset_range.end),
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// TriggerPoint::InlayHint(highlight, _, _) => {
|
||||||
|
// RangeInEditor::Inlay(highlight.clone())
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// match highlight_range {
|
||||||
|
// RangeInEditor::Text(text_range) => this
|
||||||
|
// .highlight_text::<LinkGoToDefinitionState>(
|
||||||
|
// vec![text_range],
|
||||||
|
// style,
|
||||||
|
// cx,
|
||||||
|
// ),
|
||||||
|
// RangeInEditor::Inlay(highlight) => this
|
||||||
|
// .highlight_inlays::<LinkGoToDefinitionState>(
|
||||||
|
// vec![highlight],
|
||||||
|
// style,
|
||||||
|
// cx,
|
||||||
|
// ),
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
hide_link_definition(this, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
|
||||||
|
Ok::<_, anyhow::Error>(())
|
||||||
|
}
|
||||||
|
.log_err()
|
||||||
|
});
|
||||||
|
|
||||||
|
editor.link_go_to_definition_state.task = Some(task);
|
||||||
}
|
}
|
||||||
// let same_kind = editor.link_go_to_definition_state.kind == Some(definition_kind);
|
|
||||||
// if !same_kind {
|
|
||||||
// hide_link_definition(editor, cx);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if editor.pending_rename.is_some() {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let trigger_anchor = trigger_point.anchor();
|
|
||||||
// let (buffer, buffer_position) = if let Some(output) = editor
|
|
||||||
// .buffer
|
|
||||||
// .read(cx)
|
|
||||||
// .text_anchor_for_position(trigger_anchor.clone(), cx)
|
|
||||||
// {
|
|
||||||
// output
|
|
||||||
// } else {
|
|
||||||
// return;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let excerpt_id = if let Some((excerpt_id, _, _)) = editor
|
|
||||||
// .buffer()
|
|
||||||
// .read(cx)
|
|
||||||
// .excerpt_containing(trigger_anchor.clone(), cx)
|
|
||||||
// {
|
|
||||||
// excerpt_id
|
|
||||||
// } else {
|
|
||||||
// return;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let project = if let Some(project) = editor.project.clone() {
|
|
||||||
// project
|
|
||||||
// } else {
|
|
||||||
// return;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // Don't request again if the location is within the symbol region of a previous request with the same kind
|
|
||||||
// if let Some(symbol_range) = &editor.link_go_to_definition_state.symbol_range {
|
|
||||||
// if same_kind && symbol_range.point_within_range(&trigger_point, &snapshot) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let task = cx.spawn(|this, mut cx| {
|
|
||||||
// async move {
|
|
||||||
// let result = match &trigger_point {
|
|
||||||
// TriggerPoint::Text(_) => {
|
|
||||||
// // query the LSP for definition info
|
|
||||||
// cx.update(|cx| {
|
|
||||||
// project.update(cx, |project, cx| match definition_kind {
|
|
||||||
// LinkDefinitionKind::Symbol => {
|
|
||||||
// project.definition(&buffer, buffer_position, cx)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// LinkDefinitionKind::Type => {
|
|
||||||
// project.type_definition(&buffer, buffer_position, cx)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// .await
|
|
||||||
// .ok()
|
|
||||||
// .map(|definition_result| {
|
|
||||||
// (
|
|
||||||
// definition_result.iter().find_map(|link| {
|
|
||||||
// link.origin.as_ref().map(|origin| {
|
|
||||||
// let start = snapshot
|
|
||||||
// .buffer_snapshot
|
|
||||||
// .anchor_in_excerpt(excerpt_id.clone(), origin.range.start);
|
|
||||||
// let end = snapshot
|
|
||||||
// .buffer_snapshot
|
|
||||||
// .anchor_in_excerpt(excerpt_id.clone(), origin.range.end);
|
|
||||||
// RangeInEditor::Text(start..end)
|
|
||||||
// })
|
|
||||||
// }),
|
|
||||||
// definition_result
|
|
||||||
// .into_iter()
|
|
||||||
// .map(GoToDefinitionLink::Text)
|
|
||||||
// .collect(),
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// TriggerPoint::InlayHint(highlight, lsp_location, server_id) => Some((
|
|
||||||
// Some(RangeInEditor::Inlay(highlight.clone())),
|
|
||||||
// vec![GoToDefinitionLink::InlayHint(
|
|
||||||
// lsp_location.clone(),
|
|
||||||
// *server_id,
|
|
||||||
// )],
|
|
||||||
// )),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// this.update(&mut cx, |this, cx| {
|
|
||||||
// // Clear any existing highlights
|
|
||||||
// this.clear_highlights::<LinkGoToDefinitionState>(cx);
|
|
||||||
// this.link_go_to_definition_state.kind = Some(definition_kind);
|
|
||||||
// this.link_go_to_definition_state.symbol_range = result
|
|
||||||
// .as_ref()
|
|
||||||
// .and_then(|(symbol_range, _)| symbol_range.clone());
|
|
||||||
|
|
||||||
// if let Some((symbol_range, definitions)) = result {
|
|
||||||
// this.link_go_to_definition_state.definitions = definitions.clone();
|
|
||||||
|
|
||||||
// let buffer_snapshot = buffer.read(cx).snapshot();
|
|
||||||
|
|
||||||
// // Only show highlight if there exists a definition to jump to that doesn't contain
|
|
||||||
// // the current location.
|
|
||||||
// let any_definition_does_not_contain_current_location =
|
|
||||||
// definitions.iter().any(|definition| {
|
|
||||||
// match &definition {
|
|
||||||
// GoToDefinitionLink::Text(link) => {
|
|
||||||
// if link.target.buffer == buffer {
|
|
||||||
// let range = &link.target.range;
|
|
||||||
// // Expand range by one character as lsp definition ranges include positions adjacent
|
|
||||||
// // but not contained by the symbol range
|
|
||||||
// let start = buffer_snapshot.clip_offset(
|
|
||||||
// range
|
|
||||||
// .start
|
|
||||||
// .to_offset(&buffer_snapshot)
|
|
||||||
// .saturating_sub(1),
|
|
||||||
// Bias::Left,
|
|
||||||
// );
|
|
||||||
// let end = buffer_snapshot.clip_offset(
|
|
||||||
// range.end.to_offset(&buffer_snapshot) + 1,
|
|
||||||
// Bias::Right,
|
|
||||||
// );
|
|
||||||
// let offset = buffer_position.to_offset(&buffer_snapshot);
|
|
||||||
// !(start <= offset && end >= offset)
|
|
||||||
// } else {
|
|
||||||
// true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// GoToDefinitionLink::InlayHint(_, _) => true,
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if any_definition_does_not_contain_current_location {
|
|
||||||
// // todo!()
|
|
||||||
// // // Highlight symbol using theme link definition highlight style
|
|
||||||
// // let style = theme::current(cx).editor.link_definition;
|
|
||||||
// // let highlight_range =
|
|
||||||
// // symbol_range.unwrap_or_else(|| match &trigger_point {
|
|
||||||
// // TriggerPoint::Text(trigger_anchor) => {
|
|
||||||
// // let snapshot = &snapshot.buffer_snapshot;
|
|
||||||
// // // If no symbol range returned from language server, use the surrounding word.
|
|
||||||
// // let (offset_range, _) =
|
|
||||||
// // snapshot.surrounding_word(*trigger_anchor);
|
|
||||||
// // RangeInEditor::Text(
|
|
||||||
// // snapshot.anchor_before(offset_range.start)
|
|
||||||
// // ..snapshot.anchor_after(offset_range.end),
|
|
||||||
// // )
|
|
||||||
// // }
|
|
||||||
// // TriggerPoint::InlayHint(highlight, _, _) => {
|
|
||||||
// // RangeInEditor::Inlay(highlight.clone())
|
|
||||||
// // }
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // match highlight_range {
|
|
||||||
// // RangeInEditor::Text(text_range) => this
|
|
||||||
// // .highlight_text::<LinkGoToDefinitionState>(
|
|
||||||
// // vec![text_range],
|
|
||||||
// // style,
|
|
||||||
// // cx,
|
|
||||||
// // ),
|
|
||||||
// // RangeInEditor::Inlay(highlight) => this
|
|
||||||
// // .highlight_inlays::<LinkGoToDefinitionState>(
|
|
||||||
// // vec![highlight],
|
|
||||||
// // style,
|
|
||||||
// // cx,
|
|
||||||
// // ),
|
|
||||||
// // }
|
|
||||||
// } else {
|
|
||||||
// hide_link_definition(this, cx);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })?;
|
|
||||||
|
|
||||||
// Ok::<_, anyhow::Error>(())
|
|
||||||
// }
|
|
||||||
// .log_err()
|
|
||||||
// });
|
|
||||||
|
|
||||||
// editor.link_go_to_definition_state.task = Some(task);
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn hide_link_definition(editor: &mut Editor, cx: &mut ViewContext<Editor>) {
|
pub fn hide_link_definition(editor: &mut Editor, cx: &mut ViewContext<Editor>) {
|
||||||
todo!()
|
if editor.link_go_to_definition_state.symbol_range.is_some()
|
||||||
// if editor.link_go_to_definition_state.symbol_range.is_some()
|
|| !editor.link_go_to_definition_state.definitions.is_empty()
|
||||||
// || !editor.link_go_to_definition_state.definitions.is_empty()
|
{
|
||||||
// {
|
editor.link_go_to_definition_state.symbol_range.take();
|
||||||
// editor.link_go_to_definition_state.symbol_range.take();
|
editor.link_go_to_definition_state.definitions.clear();
|
||||||
// editor.link_go_to_definition_state.definitions.clear();
|
cx.notify();
|
||||||
// cx.notify();
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// editor.link_go_to_definition_state.task = None;
|
editor.link_go_to_definition_state.task = None;
|
||||||
|
|
||||||
// editor.clear_highlights::<LinkGoToDefinitionState>(cx);
|
editor.clear_highlights::<LinkGoToDefinitionState>(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn go_to_fetched_definition(
|
pub fn go_to_fetched_definition(
|
||||||
|
@ -578,35 +575,34 @@ fn go_to_fetched_definition_of_kind(
|
||||||
split: bool,
|
split: bool,
|
||||||
cx: &mut ViewContext<Editor>,
|
cx: &mut ViewContext<Editor>,
|
||||||
) {
|
) {
|
||||||
todo!();
|
let cached_definitions = editor.link_go_to_definition_state.definitions.clone();
|
||||||
// let cached_definitions = editor.link_go_to_definition_state.definitions.clone();
|
hide_link_definition(editor, cx);
|
||||||
// hide_link_definition(editor, cx);
|
let cached_definitions_kind = editor.link_go_to_definition_state.kind;
|
||||||
// let cached_definitions_kind = editor.link_go_to_definition_state.kind;
|
|
||||||
|
|
||||||
// let is_correct_kind = cached_definitions_kind == Some(kind);
|
let is_correct_kind = cached_definitions_kind == Some(kind);
|
||||||
// if !cached_definitions.is_empty() && is_correct_kind {
|
if !cached_definitions.is_empty() && is_correct_kind {
|
||||||
// if !editor.focused {
|
if !editor.focused {
|
||||||
// cx.focus_self();
|
cx.focus(&editor.focus_handle);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// editor.navigate_to_definitions(cached_definitions, split, cx);
|
editor.navigate_to_definitions(cached_definitions, split, cx);
|
||||||
// } else {
|
} else {
|
||||||
// editor.select(
|
editor.select(
|
||||||
// SelectPhase::Begin {
|
SelectPhase::Begin {
|
||||||
// position: point.next_valid,
|
position: point.next_valid,
|
||||||
// add: false,
|
add: false,
|
||||||
// click_count: 1,
|
click_count: 1,
|
||||||
// },
|
},
|
||||||
// cx,
|
cx,
|
||||||
// );
|
);
|
||||||
|
|
||||||
// if point.as_valid().is_some() {
|
if point.as_valid().is_some() {
|
||||||
// match kind {
|
match kind {
|
||||||
// LinkDefinitionKind::Symbol => editor.go_to_definition(&Default::default(), cx),
|
LinkDefinitionKind::Symbol => editor.go_to_definition(&GoToDefinition, cx),
|
||||||
// LinkDefinitionKind::Type => editor.go_to_type_definition(&Default::default(), cx),
|
LinkDefinitionKind::Type => editor.go_to_type_definition(&GoToTypeDefinition, cx),
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(test)]
|
// #[cfg(test)]
|
||||||
|
|
|
@ -346,8 +346,7 @@ impl Editor {
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
||||||
// todo!()
|
self.refresh_inlay_hints(InlayHintRefreshReason::NewLinesShown, cx);
|
||||||
// self.refresh_inlay_hints(InlayHintRefreshReason::NewLinesShown, cx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn scroll_position(&self, cx: &mut ViewContext<Self>) -> gpui::Point<Pixels> {
|
// pub fn scroll_position(&self, cx: &mut ViewContext<Self>) -> gpui::Point<Pixels> {
|
||||||
|
|
|
@ -639,19 +639,19 @@ impl Pane {
|
||||||
// .pixel_position_of_cursor(cx)
|
// .pixel_position_of_cursor(cx)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn item_for_entry(
|
pub fn item_for_entry(
|
||||||
// &self,
|
&self,
|
||||||
// entry_id: ProjectEntryId,
|
entry_id: ProjectEntryId,
|
||||||
// cx: &AppContext,
|
cx: &AppContext,
|
||||||
// ) -> Option<Box<dyn ItemHandle>> {
|
) -> Option<Box<dyn ItemHandle>> {
|
||||||
// self.items.iter().find_map(|item| {
|
self.items.iter().find_map(|item| {
|
||||||
// if item.is_singleton(cx) && item.project_entry_ids(cx).as_slice() == [entry_id] {
|
if item.is_singleton(cx) && item.project_entry_ids(cx).as_slice() == [entry_id] {
|
||||||
// Some(item.boxed_clone())
|
Some(item.boxed_clone())
|
||||||
// } else {
|
} else {
|
||||||
// None
|
None
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn index_for_item(&self, item: &dyn ItemHandle) -> Option<usize> {
|
pub fn index_for_item(&self, item: &dyn ItemHandle) -> Option<usize> {
|
||||||
self.items.iter().position(|i| i.id() == item.id())
|
self.items.iter().position(|i| i.id() == item.id())
|
||||||
|
|
|
@ -1999,22 +1999,22 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
||||||
// self.active_pane
|
self.active_pane
|
||||||
// .update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
|
.update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn split_item(
|
pub fn split_item(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// split_direction: SplitDirection,
|
split_direction: SplitDirection,
|
||||||
// item: Box<dyn ItemHandle>,
|
item: Box<dyn ItemHandle>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) {
|
) {
|
||||||
// let new_pane = self.split_pane(self.active_pane.clone(), split_direction, cx);
|
let new_pane = self.split_pane(self.active_pane.clone(), split_direction, cx);
|
||||||
// new_pane.update(cx, move |new_pane, cx| {
|
new_pane.update(cx, move |new_pane, cx| {
|
||||||
// new_pane.add_item(item, true, true, None, cx)
|
new_pane.add_item(item, true, true, None, cx)
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn open_abs_path(
|
// pub fn open_abs_path(
|
||||||
// &mut self,
|
// &mut self,
|
||||||
|
@ -2144,53 +2144,55 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn open_project_item<T>(
|
pub fn open_project_item<T>(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// project_item: ModelHandle<T::Item>,
|
project_item: Model<T::Item>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> View<T>
|
) -> View<T>
|
||||||
// where
|
where
|
||||||
// T: ProjectItem,
|
T: ProjectItem,
|
||||||
// {
|
{
|
||||||
// use project::Item as _;
|
use project2::Item as _;
|
||||||
|
|
||||||
// let entry_id = project_item.read(cx).entry_id(cx);
|
let entry_id = project_item.read(cx).entry_id(cx);
|
||||||
// if let Some(item) = entry_id
|
if let Some(item) = entry_id
|
||||||
// .and_then(|entry_id| self.active_pane().read(cx).item_for_entry(entry_id, cx))
|
.and_then(|entry_id| self.active_pane().read(cx).item_for_entry(entry_id, cx))
|
||||||
// .and_then(|item| item.downcast())
|
.and_then(|item| item.downcast())
|
||||||
// {
|
{
|
||||||
// self.activate_item(&item, cx);
|
self.activate_item(&item, cx);
|
||||||
// return item;
|
return item;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// let item = cx.build_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
let item =
|
||||||
// self.add_item(Box::new(item.clone()), cx);
|
cx.build_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
||||||
// item
|
self.add_item(Box::new(item.clone()), cx);
|
||||||
// }
|
item
|
||||||
|
}
|
||||||
|
|
||||||
// pub fn split_project_item<T>(
|
pub fn split_project_item<T>(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// project_item: ModelHandle<T::Item>,
|
project_item: Model<T::Item>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> View<T>
|
) -> View<T>
|
||||||
// where
|
where
|
||||||
// T: ProjectItem,
|
T: ProjectItem,
|
||||||
// {
|
{
|
||||||
// use project::Item as _;
|
use project2::Item as _;
|
||||||
|
|
||||||
// let entry_id = project_item.read(cx).entry_id(cx);
|
let entry_id = project_item.read(cx).entry_id(cx);
|
||||||
// if let Some(item) = entry_id
|
if let Some(item) = entry_id
|
||||||
// .and_then(|entry_id| self.active_pane().read(cx).item_for_entry(entry_id, cx))
|
.and_then(|entry_id| self.active_pane().read(cx).item_for_entry(entry_id, cx))
|
||||||
// .and_then(|item| item.downcast())
|
.and_then(|item| item.downcast())
|
||||||
// {
|
{
|
||||||
// self.activate_item(&item, cx);
|
self.activate_item(&item, cx);
|
||||||
// return item;
|
return item;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// let item = cx.build_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
let item =
|
||||||
// self.split_item(SplitDirection::Right, Box::new(item.clone()), cx);
|
cx.build_view(|cx| T::for_project_item(self.project().clone(), project_item, cx));
|
||||||
// item
|
self.split_item(SplitDirection::Right, Box::new(item.clone()), cx);
|
||||||
// }
|
item
|
||||||
|
}
|
||||||
|
|
||||||
// pub fn open_shared_screen(&mut self, peer_id: PeerId, cx: &mut ViewContext<Self>) {
|
// pub fn open_shared_screen(&mut self, peer_id: PeerId, cx: &mut ViewContext<Self>) {
|
||||||
// if let Some(shared_screen) = self.shared_screen_for_peer(peer_id, &self.active_pane, cx) {
|
// if let Some(shared_screen) = self.shared_screen_for_peer(peer_id, &self.active_pane, cx) {
|
||||||
|
@ -2200,19 +2202,19 @@ impl Workspace {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn activate_item(&mut self, item: &dyn ItemHandle, cx: &mut ViewContext<Self>) -> bool {
|
pub fn activate_item(&mut self, item: &dyn ItemHandle, cx: &mut ViewContext<Self>) -> bool {
|
||||||
// let result = self.panes.iter().find_map(|pane| {
|
let result = self.panes.iter().find_map(|pane| {
|
||||||
// pane.read(cx)
|
pane.read(cx)
|
||||||
// .index_for_item(item)
|
.index_for_item(item)
|
||||||
// .map(|ix| (pane.clone(), ix))
|
.map(|ix| (pane.clone(), ix))
|
||||||
// });
|
});
|
||||||
// if let Some((pane, ix)) = result {
|
if let Some((pane, ix)) = result {
|
||||||
// pane.update(cx, |pane, cx| pane.activate_item(ix, true, true, cx));
|
pane.update(cx, |pane, cx| pane.activate_item(ix, true, true, cx));
|
||||||
// true
|
true
|
||||||
// } else {
|
} else {
|
||||||
// false
|
false
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// fn activate_pane_at_index(&mut self, action: &ActivatePane, cx: &mut ViewContext<Self>) {
|
// fn activate_pane_at_index(&mut self, action: &ActivatePane, cx: &mut ViewContext<Self>) {
|
||||||
// let panes = self.center.panes();
|
// let panes = self.center.panes();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue