Merge remote-tracking branch 'origin/main' into editor2-rename
# Conflicts: # crates/editor2/src/editor.rs # crates/editor2/src/element.rs # crates/gpui2/src/style.rs
This commit is contained in:
@@ -39,12 +39,12 @@ use futures::FutureExt;
|
||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||
use git::diff_hunk_to_display;
|
||||
use gpui::{
|
||||
action, actions, div, point, px, relative, rems, render_view, size, uniform_list, AnyElement,
|
||||
AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Component, Context,
|
||||
Entity, EventEmitter, FocusHandle, FontFeatures, FontStyle, FontWeight, HighlightStyle, Hsla,
|
||||
InputHandler, KeyContext, Model, MouseButton, ParentElement, Pixels, Render,
|
||||
StatefulInteractive, StatelessInteractive, Styled, Subscription, Task, TextStyle,
|
||||
UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||
action, actions, div, point, prelude::*, px, relative, rems, render_view, size, uniform_list,
|
||||
AnyElement, AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem,
|
||||
Component, Context, EventEmitter, FocusHandle, FontFeatures, FontStyle, FontWeight,
|
||||
HighlightStyle, Hsla, InputHandler, KeyContext, Model, MouseButton, ParentComponent, Pixels,
|
||||
Render, Styled, Subscription, Task, TextStyle, UniformListScrollHandle, View, ViewContext,
|
||||
VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||
use hover_popover::{hide_hover, HoverState};
|
||||
@@ -7808,17 +7808,22 @@ impl Editor {
|
||||
.pl(cx.anchor_x)
|
||||
.child(render_view(
|
||||
&rename_editor,
|
||||
EditorElement::new(EditorStyle {
|
||||
background: cx.theme().system().transparent,
|
||||
local_player: cx.editor_style.local_player,
|
||||
text: text_style,
|
||||
scrollbar_width: cx.editor_style.scrollbar_width,
|
||||
syntax: cx.editor_style.syntax.clone(),
|
||||
diagnostic_style: cx
|
||||
.editor_style
|
||||
.diagnostic_style
|
||||
.clone(),
|
||||
}),
|
||||
EditorElement::new(
|
||||
&rename_editor,
|
||||
EditorStyle {
|
||||
background: cx.theme().system().transparent,
|
||||
local_player: cx.editor_style.local_player,
|
||||
text: text_style,
|
||||
scrollbar_width: cx
|
||||
.editor_style
|
||||
.scrollbar_width,
|
||||
syntax: cx.editor_style.syntax.clone(),
|
||||
diagnostic_style: cx
|
||||
.editor_style
|
||||
.diagnostic_style
|
||||
.clone(),
|
||||
},
|
||||
),
|
||||
))
|
||||
.render()
|
||||
}
|
||||
@@ -9192,6 +9197,10 @@ impl Editor {
|
||||
cx.focus(&self.focus_handle)
|
||||
}
|
||||
|
||||
pub fn is_focused(&self, cx: &WindowContext) -> bool {
|
||||
self.focus_handle.is_focused(cx)
|
||||
}
|
||||
|
||||
fn handle_focus_in(&mut self, cx: &mut ViewContext<Self>) {
|
||||
if self.focus_handle.is_focused(cx) {
|
||||
// todo!()
|
||||
@@ -9403,8 +9412,8 @@ impl Render for Editor {
|
||||
EditorMode::SingleLine => {
|
||||
TextStyle {
|
||||
color: cx.theme().colors().text,
|
||||
font_family: "Zed Sans".into(), // todo!()
|
||||
font_features: FontFeatures::default(),
|
||||
font_family: settings.ui_font.family.clone(), // todo!()
|
||||
font_features: settings.ui_font.features,
|
||||
font_size: rems(0.875).into(),
|
||||
font_weight: FontWeight::NORMAL,
|
||||
font_style: FontStyle::Normal,
|
||||
@@ -9433,14 +9442,17 @@ impl Render for Editor {
|
||||
EditorMode::Full => cx.theme().colors().editor_background,
|
||||
};
|
||||
|
||||
EditorElement::new(EditorStyle {
|
||||
background,
|
||||
local_player: cx.theme().players().local(),
|
||||
text: text_style,
|
||||
scrollbar_width: px(12.),
|
||||
syntax: cx.theme().syntax().clone(),
|
||||
diagnostic_style: cx.theme().diagnostic_style(),
|
||||
})
|
||||
EditorElement::new(
|
||||
cx.view(),
|
||||
EditorStyle {
|
||||
background,
|
||||
local_player: cx.theme().players().local(),
|
||||
text: text_style,
|
||||
scrollbar_width: px(12.),
|
||||
syntax: cx.theme().syntax().clone(),
|
||||
diagnostic_style: cx.theme().diagnostic_style(),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+212
-211
@@ -20,9 +20,9 @@ use collections::{BTreeMap, HashMap};
|
||||
use gpui::{
|
||||
point, px, relative, size, transparent_black, Action, AnyElement, AvailableSpace, BorrowWindow,
|
||||
Bounds, Component, ContentMask, Corners, DispatchPhase, Edges, Element, ElementId,
|
||||
ElementInputHandler, Entity, Hsla, Line, MouseButton, MouseDownEvent, MouseMoveEvent,
|
||||
MouseUpEvent, ParentElement, Pixels, ScrollWheelEvent, Size, Style, Styled, TextRun, TextStyle,
|
||||
ViewContext, WindowContext,
|
||||
ElementInputHandler, Entity, EntityId, Hsla, Line, MouseButton, MouseDownEvent, MouseMoveEvent,
|
||||
MouseUpEvent, ParentComponent, Pixels, ScrollWheelEvent, Size, Style, Styled, TextRun,
|
||||
TextStyle, View, ViewContext, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::language_settings::ShowWhitespaceSetting;
|
||||
@@ -111,12 +111,16 @@ impl SelectionLayout {
|
||||
}
|
||||
|
||||
pub struct EditorElement {
|
||||
editor_id: EntityId,
|
||||
style: EditorStyle,
|
||||
}
|
||||
|
||||
impl EditorElement {
|
||||
pub fn new(style: EditorStyle) -> Self {
|
||||
Self { style }
|
||||
pub fn new(editor: &View<Editor>, style: EditorStyle) -> Self {
|
||||
Self {
|
||||
editor_id: editor.entity_id(),
|
||||
style,
|
||||
}
|
||||
}
|
||||
|
||||
fn mouse_down(
|
||||
@@ -622,7 +626,7 @@ impl EditorElement {
|
||||
let line_end_overshoot = 0.15 * layout.position_map.line_height;
|
||||
let whitespace_setting = editor.buffer.read(cx).settings_at(0, cx).show_whitespaces;
|
||||
|
||||
cx.with_content_mask(ContentMask { bounds }, |cx| {
|
||||
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
||||
// todo!("cursor region")
|
||||
// cx.scene().push_cursor_region(CursorRegion {
|
||||
// bounds,
|
||||
@@ -1448,6 +1452,7 @@ impl EditorElement {
|
||||
|
||||
let snapshot = editor.snapshot(cx);
|
||||
let style = self.style.clone();
|
||||
|
||||
let font_id = cx.text_system().font_id(&style.text.font()).unwrap();
|
||||
let font_size = style.text.font_size.to_pixels(cx.rem_size());
|
||||
let line_height = style.text.line_height_in_pixels(cx.rem_size());
|
||||
@@ -2399,8 +2404,8 @@ enum Invisible {
|
||||
impl Element<Editor> for EditorElement {
|
||||
type ElementState = ();
|
||||
|
||||
fn id(&self) -> Option<gpui::ElementId> {
|
||||
None
|
||||
fn element_id(&self) -> Option<gpui::ElementId> {
|
||||
Some(self.editor_id.into())
|
||||
}
|
||||
|
||||
fn initialize(
|
||||
@@ -2410,186 +2415,6 @@ impl Element<Editor> for EditorElement {
|
||||
cx: &mut gpui::ViewContext<Editor>,
|
||||
) -> Self::ElementState {
|
||||
editor.style = Some(self.style.clone()); // Long-term, we'd like to eliminate this.
|
||||
|
||||
let dispatch_context = editor.dispatch_context(cx);
|
||||
cx.with_element_id(cx.view().entity_id(), |global_id, cx| {
|
||||
cx.with_key_dispatch(
|
||||
dispatch_context,
|
||||
Some(editor.focus_handle.clone()),
|
||||
|_, cx| {
|
||||
register_action(cx, Editor::move_left);
|
||||
register_action(cx, Editor::move_right);
|
||||
register_action(cx, Editor::move_down);
|
||||
register_action(cx, Editor::move_up);
|
||||
// on_action(cx, Editor::new_file); todo!()
|
||||
// on_action(cx, Editor::new_file_in_direction); todo!()
|
||||
register_action(cx, Editor::cancel);
|
||||
register_action(cx, Editor::newline);
|
||||
register_action(cx, Editor::newline_above);
|
||||
register_action(cx, Editor::newline_below);
|
||||
register_action(cx, Editor::backspace);
|
||||
register_action(cx, Editor::delete);
|
||||
register_action(cx, Editor::tab);
|
||||
register_action(cx, Editor::tab_prev);
|
||||
register_action(cx, Editor::indent);
|
||||
register_action(cx, Editor::outdent);
|
||||
register_action(cx, Editor::delete_line);
|
||||
register_action(cx, Editor::join_lines);
|
||||
register_action(cx, Editor::sort_lines_case_sensitive);
|
||||
register_action(cx, Editor::sort_lines_case_insensitive);
|
||||
register_action(cx, Editor::reverse_lines);
|
||||
register_action(cx, Editor::shuffle_lines);
|
||||
register_action(cx, Editor::convert_to_upper_case);
|
||||
register_action(cx, Editor::convert_to_lower_case);
|
||||
register_action(cx, Editor::convert_to_title_case);
|
||||
register_action(cx, Editor::convert_to_snake_case);
|
||||
register_action(cx, Editor::convert_to_kebab_case);
|
||||
register_action(cx, Editor::convert_to_upper_camel_case);
|
||||
register_action(cx, Editor::convert_to_lower_camel_case);
|
||||
register_action(cx, Editor::delete_to_previous_word_start);
|
||||
register_action(cx, Editor::delete_to_previous_subword_start);
|
||||
register_action(cx, Editor::delete_to_next_word_end);
|
||||
register_action(cx, Editor::delete_to_next_subword_end);
|
||||
register_action(cx, Editor::delete_to_beginning_of_line);
|
||||
register_action(cx, Editor::delete_to_end_of_line);
|
||||
register_action(cx, Editor::cut_to_end_of_line);
|
||||
register_action(cx, Editor::duplicate_line);
|
||||
register_action(cx, Editor::move_line_up);
|
||||
register_action(cx, Editor::move_line_down);
|
||||
register_action(cx, Editor::transpose);
|
||||
register_action(cx, Editor::cut);
|
||||
register_action(cx, Editor::copy);
|
||||
register_action(cx, Editor::paste);
|
||||
register_action(cx, Editor::undo);
|
||||
register_action(cx, Editor::redo);
|
||||
register_action(cx, Editor::move_page_up);
|
||||
register_action(cx, Editor::move_page_down);
|
||||
register_action(cx, Editor::next_screen);
|
||||
register_action(cx, Editor::scroll_cursor_top);
|
||||
register_action(cx, Editor::scroll_cursor_center);
|
||||
register_action(cx, Editor::scroll_cursor_bottom);
|
||||
register_action(cx, |editor, _: &LineDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Line(1.), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &LineUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Line(-1.), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &HalfPageDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(0.5), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &HalfPageUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(-0.5), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &PageDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(1.), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &PageUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(-1.), cx)
|
||||
});
|
||||
register_action(cx, Editor::move_to_previous_word_start);
|
||||
register_action(cx, Editor::move_to_previous_subword_start);
|
||||
register_action(cx, Editor::move_to_next_word_end);
|
||||
register_action(cx, Editor::move_to_next_subword_end);
|
||||
register_action(cx, Editor::move_to_beginning_of_line);
|
||||
register_action(cx, Editor::move_to_end_of_line);
|
||||
register_action(cx, Editor::move_to_start_of_paragraph);
|
||||
register_action(cx, Editor::move_to_end_of_paragraph);
|
||||
register_action(cx, Editor::move_to_beginning);
|
||||
register_action(cx, Editor::move_to_end);
|
||||
register_action(cx, Editor::select_up);
|
||||
register_action(cx, Editor::select_down);
|
||||
register_action(cx, Editor::select_left);
|
||||
register_action(cx, Editor::select_right);
|
||||
register_action(cx, Editor::select_to_previous_word_start);
|
||||
register_action(cx, Editor::select_to_previous_subword_start);
|
||||
register_action(cx, Editor::select_to_next_word_end);
|
||||
register_action(cx, Editor::select_to_next_subword_end);
|
||||
register_action(cx, Editor::select_to_beginning_of_line);
|
||||
register_action(cx, Editor::select_to_end_of_line);
|
||||
register_action(cx, Editor::select_to_start_of_paragraph);
|
||||
register_action(cx, Editor::select_to_end_of_paragraph);
|
||||
register_action(cx, Editor::select_to_beginning);
|
||||
register_action(cx, Editor::select_to_end);
|
||||
register_action(cx, Editor::select_all);
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor.select_all_matches(action, cx).log_err();
|
||||
});
|
||||
register_action(cx, Editor::select_line);
|
||||
register_action(cx, Editor::split_selection_into_lines);
|
||||
register_action(cx, Editor::add_selection_above);
|
||||
register_action(cx, Editor::add_selection_below);
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor.select_next(action, cx).log_err();
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor.select_previous(action, cx).log_err();
|
||||
});
|
||||
register_action(cx, Editor::toggle_comments);
|
||||
register_action(cx, Editor::select_larger_syntax_node);
|
||||
register_action(cx, Editor::select_smaller_syntax_node);
|
||||
register_action(cx, Editor::move_to_enclosing_bracket);
|
||||
register_action(cx, Editor::undo_selection);
|
||||
register_action(cx, Editor::redo_selection);
|
||||
register_action(cx, Editor::go_to_diagnostic);
|
||||
register_action(cx, Editor::go_to_prev_diagnostic);
|
||||
register_action(cx, Editor::go_to_hunk);
|
||||
register_action(cx, Editor::go_to_prev_hunk);
|
||||
register_action(cx, Editor::go_to_definition);
|
||||
register_action(cx, Editor::go_to_definition_split);
|
||||
register_action(cx, Editor::go_to_type_definition);
|
||||
register_action(cx, Editor::go_to_type_definition_split);
|
||||
register_action(cx, Editor::fold);
|
||||
register_action(cx, Editor::fold_at);
|
||||
register_action(cx, Editor::unfold_lines);
|
||||
register_action(cx, Editor::unfold_at);
|
||||
register_action(cx, Editor::fold_selected_ranges);
|
||||
register_action(cx, Editor::show_completions);
|
||||
register_action(cx, Editor::toggle_code_actions);
|
||||
// on_action(cx, Editor::open_excerpts); todo!()
|
||||
register_action(cx, Editor::toggle_soft_wrap);
|
||||
register_action(cx, Editor::toggle_inlay_hints);
|
||||
register_action(cx, Editor::reveal_in_finder);
|
||||
register_action(cx, Editor::copy_path);
|
||||
register_action(cx, Editor::copy_relative_path);
|
||||
register_action(cx, Editor::copy_highlight_json);
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.format(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, Editor::restart_language_server);
|
||||
register_action(cx, Editor::show_character_palette);
|
||||
// on_action(cx, Editor::confirm_completion); todo!()
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.confirm_code_action(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.rename(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.confirm_rename(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.find_all_references(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, Editor::next_copilot_suggestion);
|
||||
register_action(cx, Editor::previous_copilot_suggestion);
|
||||
register_action(cx, Editor::copilot_suggest);
|
||||
register_action(cx, Editor::context_menu_first);
|
||||
register_action(cx, Editor::context_menu_prev);
|
||||
register_action(cx, Editor::context_menu_next);
|
||||
register_action(cx, Editor::context_menu_last);
|
||||
},
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
fn layout(
|
||||
@@ -2626,32 +2451,208 @@ impl Element<Editor> for EditorElement {
|
||||
size: layout.text_size,
|
||||
};
|
||||
|
||||
// We call with_z_index to establish a new stacking context.
|
||||
cx.with_z_index(0, |cx| {
|
||||
cx.with_content_mask(ContentMask { bounds }, |cx| {
|
||||
self.paint_mouse_listeners(
|
||||
bounds,
|
||||
gutter_bounds,
|
||||
text_bounds,
|
||||
&layout.position_map,
|
||||
cx,
|
||||
);
|
||||
let dispatch_context = editor.dispatch_context(cx);
|
||||
cx.with_key_dispatch(
|
||||
dispatch_context,
|
||||
Some(editor.focus_handle.clone()),
|
||||
|_, cx| {
|
||||
register_action(cx, Editor::move_left);
|
||||
register_action(cx, Editor::move_right);
|
||||
register_action(cx, Editor::move_down);
|
||||
register_action(cx, Editor::move_up);
|
||||
// on_action(cx, Editor::new_file); todo!()
|
||||
// on_action(cx, Editor::new_file_in_direction); todo!()
|
||||
register_action(cx, Editor::cancel);
|
||||
register_action(cx, Editor::newline);
|
||||
register_action(cx, Editor::newline_above);
|
||||
register_action(cx, Editor::newline_below);
|
||||
register_action(cx, Editor::backspace);
|
||||
register_action(cx, Editor::delete);
|
||||
register_action(cx, Editor::tab);
|
||||
register_action(cx, Editor::tab_prev);
|
||||
register_action(cx, Editor::indent);
|
||||
register_action(cx, Editor::outdent);
|
||||
register_action(cx, Editor::delete_line);
|
||||
register_action(cx, Editor::join_lines);
|
||||
register_action(cx, Editor::sort_lines_case_sensitive);
|
||||
register_action(cx, Editor::sort_lines_case_insensitive);
|
||||
register_action(cx, Editor::reverse_lines);
|
||||
register_action(cx, Editor::shuffle_lines);
|
||||
register_action(cx, Editor::convert_to_upper_case);
|
||||
register_action(cx, Editor::convert_to_lower_case);
|
||||
register_action(cx, Editor::convert_to_title_case);
|
||||
register_action(cx, Editor::convert_to_snake_case);
|
||||
register_action(cx, Editor::convert_to_kebab_case);
|
||||
register_action(cx, Editor::convert_to_upper_camel_case);
|
||||
register_action(cx, Editor::convert_to_lower_camel_case);
|
||||
register_action(cx, Editor::delete_to_previous_word_start);
|
||||
register_action(cx, Editor::delete_to_previous_subword_start);
|
||||
register_action(cx, Editor::delete_to_next_word_end);
|
||||
register_action(cx, Editor::delete_to_next_subword_end);
|
||||
register_action(cx, Editor::delete_to_beginning_of_line);
|
||||
register_action(cx, Editor::delete_to_end_of_line);
|
||||
register_action(cx, Editor::cut_to_end_of_line);
|
||||
register_action(cx, Editor::duplicate_line);
|
||||
register_action(cx, Editor::move_line_up);
|
||||
register_action(cx, Editor::move_line_down);
|
||||
register_action(cx, Editor::transpose);
|
||||
register_action(cx, Editor::cut);
|
||||
register_action(cx, Editor::copy);
|
||||
register_action(cx, Editor::paste);
|
||||
register_action(cx, Editor::undo);
|
||||
register_action(cx, Editor::redo);
|
||||
register_action(cx, Editor::move_page_up);
|
||||
register_action(cx, Editor::move_page_down);
|
||||
register_action(cx, Editor::next_screen);
|
||||
register_action(cx, Editor::scroll_cursor_top);
|
||||
register_action(cx, Editor::scroll_cursor_center);
|
||||
register_action(cx, Editor::scroll_cursor_bottom);
|
||||
register_action(cx, |editor, _: &LineDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Line(1.), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &LineUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Line(-1.), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &HalfPageDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(0.5), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &HalfPageUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(-0.5), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &PageDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(1.), cx)
|
||||
});
|
||||
register_action(cx, |editor, _: &PageUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(-1.), cx)
|
||||
});
|
||||
register_action(cx, Editor::move_to_previous_word_start);
|
||||
register_action(cx, Editor::move_to_previous_subword_start);
|
||||
register_action(cx, Editor::move_to_next_word_end);
|
||||
register_action(cx, Editor::move_to_next_subword_end);
|
||||
register_action(cx, Editor::move_to_beginning_of_line);
|
||||
register_action(cx, Editor::move_to_end_of_line);
|
||||
register_action(cx, Editor::move_to_start_of_paragraph);
|
||||
register_action(cx, Editor::move_to_end_of_paragraph);
|
||||
register_action(cx, Editor::move_to_beginning);
|
||||
register_action(cx, Editor::move_to_end);
|
||||
register_action(cx, Editor::select_up);
|
||||
register_action(cx, Editor::select_down);
|
||||
register_action(cx, Editor::select_left);
|
||||
register_action(cx, Editor::select_right);
|
||||
register_action(cx, Editor::select_to_previous_word_start);
|
||||
register_action(cx, Editor::select_to_previous_subword_start);
|
||||
register_action(cx, Editor::select_to_next_word_end);
|
||||
register_action(cx, Editor::select_to_next_subword_end);
|
||||
register_action(cx, Editor::select_to_beginning_of_line);
|
||||
register_action(cx, Editor::select_to_end_of_line);
|
||||
register_action(cx, Editor::select_to_start_of_paragraph);
|
||||
register_action(cx, Editor::select_to_end_of_paragraph);
|
||||
register_action(cx, Editor::select_to_beginning);
|
||||
register_action(cx, Editor::select_to_end);
|
||||
register_action(cx, Editor::select_all);
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor.select_all_matches(action, cx).log_err();
|
||||
});
|
||||
register_action(cx, Editor::select_line);
|
||||
register_action(cx, Editor::split_selection_into_lines);
|
||||
register_action(cx, Editor::add_selection_above);
|
||||
register_action(cx, Editor::add_selection_below);
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor.select_next(action, cx).log_err();
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor.select_previous(action, cx).log_err();
|
||||
});
|
||||
register_action(cx, Editor::toggle_comments);
|
||||
register_action(cx, Editor::select_larger_syntax_node);
|
||||
register_action(cx, Editor::select_smaller_syntax_node);
|
||||
register_action(cx, Editor::move_to_enclosing_bracket);
|
||||
register_action(cx, Editor::undo_selection);
|
||||
register_action(cx, Editor::redo_selection);
|
||||
register_action(cx, Editor::go_to_diagnostic);
|
||||
register_action(cx, Editor::go_to_prev_diagnostic);
|
||||
register_action(cx, Editor::go_to_hunk);
|
||||
register_action(cx, Editor::go_to_prev_hunk);
|
||||
register_action(cx, Editor::go_to_definition);
|
||||
register_action(cx, Editor::go_to_definition_split);
|
||||
register_action(cx, Editor::go_to_type_definition);
|
||||
register_action(cx, Editor::go_to_type_definition_split);
|
||||
register_action(cx, Editor::fold);
|
||||
register_action(cx, Editor::fold_at);
|
||||
register_action(cx, Editor::unfold_lines);
|
||||
register_action(cx, Editor::unfold_at);
|
||||
register_action(cx, Editor::fold_selected_ranges);
|
||||
register_action(cx, Editor::show_completions);
|
||||
register_action(cx, Editor::toggle_code_actions);
|
||||
// on_action(cx, Editor::open_excerpts); todo!()
|
||||
register_action(cx, Editor::toggle_soft_wrap);
|
||||
register_action(cx, Editor::toggle_inlay_hints);
|
||||
register_action(cx, Editor::reveal_in_finder);
|
||||
register_action(cx, Editor::copy_path);
|
||||
register_action(cx, Editor::copy_relative_path);
|
||||
register_action(cx, Editor::copy_highlight_json);
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.format(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, Editor::restart_language_server);
|
||||
register_action(cx, Editor::show_character_palette);
|
||||
// on_action(cx, Editor::confirm_completion); todo!()
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.confirm_code_action(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.rename(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.confirm_rename(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, |editor, action, cx| {
|
||||
editor
|
||||
.find_all_references(action, cx)
|
||||
.map(|task| task.detach_and_log_err(cx));
|
||||
});
|
||||
register_action(cx, Editor::next_copilot_suggestion);
|
||||
register_action(cx, Editor::previous_copilot_suggestion);
|
||||
register_action(cx, Editor::copilot_suggest);
|
||||
register_action(cx, Editor::context_menu_first);
|
||||
register_action(cx, Editor::context_menu_prev);
|
||||
register_action(cx, Editor::context_menu_next);
|
||||
register_action(cx, Editor::context_menu_last);
|
||||
|
||||
self.paint_background(gutter_bounds, text_bounds, &layout, cx);
|
||||
if layout.gutter_size.width > Pixels::ZERO {
|
||||
self.paint_gutter(gutter_bounds, &mut layout, editor, cx);
|
||||
}
|
||||
// We call with_z_index to establish a new stacking context.
|
||||
cx.with_z_index(0, |cx| {
|
||||
cx.with_content_mask(Some(ContentMask { bounds }), |cx| {
|
||||
self.paint_mouse_listeners(
|
||||
bounds,
|
||||
gutter_bounds,
|
||||
text_bounds,
|
||||
&layout.position_map,
|
||||
cx,
|
||||
);
|
||||
self.paint_background(gutter_bounds, text_bounds, &layout, cx);
|
||||
if layout.gutter_size.width > Pixels::ZERO {
|
||||
self.paint_gutter(gutter_bounds, &mut layout, editor, cx);
|
||||
}
|
||||
self.paint_text(text_bounds, &mut layout, editor, cx);
|
||||
|
||||
self.paint_text(text_bounds, &mut layout, editor, cx);
|
||||
if !layout.blocks.is_empty() {
|
||||
self.paint_blocks(bounds, &mut layout, editor, cx);
|
||||
}
|
||||
|
||||
if !layout.blocks.is_empty() {
|
||||
self.paint_blocks(bounds, &mut layout, editor, cx);
|
||||
}
|
||||
|
||||
let input_handler = ElementInputHandler::new(bounds, cx);
|
||||
cx.handle_input(&editor.focus_handle, input_handler);
|
||||
});
|
||||
});
|
||||
let input_handler = ElementInputHandler::new(bounds, cx);
|
||||
cx.handle_input(&editor.focus_handle, input_handler);
|
||||
});
|
||||
});
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use collections::HashSet;
|
||||
use futures::future::try_join_all;
|
||||
use gpui::{
|
||||
div, point, AnyElement, AppContext, AsyncAppContext, Entity, EntityId, EventEmitter,
|
||||
FocusHandle, Model, ParentElement, Pixels, SharedString, Styled, Subscription, Task, View,
|
||||
FocusHandle, Model, ParentComponent, Pixels, SharedString, Styled, Subscription, Task, View,
|
||||
ViewContext, VisualContext, WeakView,
|
||||
};
|
||||
use language::{
|
||||
@@ -30,7 +30,7 @@ use std::{
|
||||
};
|
||||
use text::Selection;
|
||||
use theme::{ActiveTheme, Theme};
|
||||
use ui::{Label, LabelColor};
|
||||
use ui::{Label, TextColor};
|
||||
use util::{paths::PathExt, ResultExt, TryFutureExt};
|
||||
use workspace::item::{BreadcrumbText, FollowEvent, FollowableEvents, FollowableItemHandle};
|
||||
use workspace::{
|
||||
@@ -607,7 +607,7 @@ impl Item for Editor {
|
||||
&description,
|
||||
MAX_TAB_TITLE_LEN,
|
||||
))
|
||||
.color(LabelColor::Muted),
|
||||
.color(TextColor::Muted),
|
||||
),
|
||||
)
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user