mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 15:44:20 +03:00
parent
7a05db6d3d
commit
6bbe9a2253
@ -6,7 +6,7 @@ use anyhow::{anyhow, Result};
|
|||||||
use assistant_slash_command::SlashCommandRegistry;
|
use assistant_slash_command::SlashCommandRegistry;
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use editor::{actions::Tab, Editor, EditorEvent};
|
use editor::{actions::Tab, CurrentLineHighlight, Editor, EditorEvent};
|
||||||
use futures::{
|
use futures::{
|
||||||
future::{self, BoxFuture, Shared},
|
future::{self, BoxFuture, Shared},
|
||||||
FutureExt,
|
FutureExt,
|
||||||
@ -125,7 +125,7 @@ struct PromptPickerDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum PromptPickerEvent {
|
enum PromptPickerEvent {
|
||||||
Selected { prompt_id: PromptId },
|
Selected { prompt_id: Option<PromptId> },
|
||||||
Confirmed { prompt_id: PromptId },
|
Confirmed { prompt_id: PromptId },
|
||||||
Deleted { prompt_id: PromptId },
|
Deleted { prompt_id: PromptId },
|
||||||
ToggledDefault { prompt_id: PromptId },
|
ToggledDefault { prompt_id: PromptId },
|
||||||
@ -164,11 +164,14 @@ impl PickerDelegate for PromptPickerDelegate {
|
|||||||
|
|
||||||
fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>) {
|
fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>) {
|
||||||
self.selected_index = ix;
|
self.selected_index = ix;
|
||||||
if let Some(PromptPickerEntry::Prompt(prompt)) = self.entries.get(self.selected_index) {
|
let prompt_id = if let Some(PromptPickerEntry::Prompt(prompt)) =
|
||||||
cx.emit(PromptPickerEvent::Selected {
|
self.entries.get(self.selected_index)
|
||||||
prompt_id: prompt.id,
|
{
|
||||||
});
|
Some(prompt.id)
|
||||||
}
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
cx.emit(PromptPickerEvent::Selected { prompt_id });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc<str> {
|
fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc<str> {
|
||||||
@ -355,7 +358,11 @@ impl PromptLibrary {
|
|||||||
) {
|
) {
|
||||||
match event {
|
match event {
|
||||||
PromptPickerEvent::Selected { prompt_id } => {
|
PromptPickerEvent::Selected { prompt_id } => {
|
||||||
self.load_prompt(*prompt_id, false, cx);
|
if let Some(prompt_id) = *prompt_id {
|
||||||
|
self.load_prompt(prompt_id, false, cx);
|
||||||
|
} else {
|
||||||
|
self.focus_picker(&Default::default(), cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PromptPickerEvent::Confirmed { prompt_id } => {
|
PromptPickerEvent::Confirmed { prompt_id } => {
|
||||||
self.load_prompt(*prompt_id, true, cx);
|
self.load_prompt(*prompt_id, true, cx);
|
||||||
@ -499,6 +506,7 @@ impl PromptLibrary {
|
|||||||
editor.set_show_gutter(false, cx);
|
editor.set_show_gutter(false, cx);
|
||||||
editor.set_show_wrap_guides(false, cx);
|
editor.set_show_wrap_guides(false, cx);
|
||||||
editor.set_show_indent_guides(false, cx);
|
editor.set_show_indent_guides(false, cx);
|
||||||
|
editor.set_current_line_highlight(Some(CurrentLineHighlight::None));
|
||||||
editor.set_completion_provider(Box::new(
|
editor.set_completion_provider(Box::new(
|
||||||
SlashCommandCompletionProvider::new(commands, None, None),
|
SlashCommandCompletionProvider::new(commands, None, None),
|
||||||
));
|
));
|
||||||
|
@ -53,8 +53,7 @@ use convert_case::{Case, Casing};
|
|||||||
use debounced_delay::DebouncedDelay;
|
use debounced_delay::DebouncedDelay;
|
||||||
use display_map::*;
|
use display_map::*;
|
||||||
pub use display_map::{DisplayPoint, FoldPlaceholder};
|
pub use display_map::{DisplayPoint, FoldPlaceholder};
|
||||||
use editor_settings::CurrentLineHighlight;
|
pub use editor_settings::{CurrentLineHighlight, EditorSettings};
|
||||||
pub use editor_settings::EditorSettings;
|
|
||||||
use element::LineWithInvisibles;
|
use element::LineWithInvisibles;
|
||||||
pub use element::{
|
pub use element::{
|
||||||
CursorLayout, EditorElement, HighlightedRange, HighlightedRangeLine, PointForPosition,
|
CursorLayout, EditorElement, HighlightedRange, HighlightedRangeLine, PointForPosition,
|
||||||
@ -480,7 +479,7 @@ pub struct Editor {
|
|||||||
pending_rename: Option<RenameState>,
|
pending_rename: Option<RenameState>,
|
||||||
searchable: bool,
|
searchable: bool,
|
||||||
cursor_shape: CursorShape,
|
cursor_shape: CursorShape,
|
||||||
current_line_highlight: CurrentLineHighlight,
|
current_line_highlight: Option<CurrentLineHighlight>,
|
||||||
collapse_matches: bool,
|
collapse_matches: bool,
|
||||||
autoindent_mode: Option<AutoindentMode>,
|
autoindent_mode: Option<AutoindentMode>,
|
||||||
workspace: Option<(WeakView<Workspace>, Option<WorkspaceId>)>,
|
workspace: Option<(WeakView<Workspace>, Option<WorkspaceId>)>,
|
||||||
@ -1768,7 +1767,7 @@ impl Editor {
|
|||||||
pending_rename: Default::default(),
|
pending_rename: Default::default(),
|
||||||
searchable: true,
|
searchable: true,
|
||||||
cursor_shape: Default::default(),
|
cursor_shape: Default::default(),
|
||||||
current_line_highlight: EditorSettings::get_global(cx).current_line_highlight,
|
current_line_highlight: None,
|
||||||
autoindent_mode: Some(AutoindentMode::EachLine),
|
autoindent_mode: Some(AutoindentMode::EachLine),
|
||||||
collapse_matches: false,
|
collapse_matches: false,
|
||||||
workspace: None,
|
workspace: None,
|
||||||
@ -1992,7 +1991,9 @@ impl Editor {
|
|||||||
ongoing_scroll: self.scroll_manager.ongoing_scroll(),
|
ongoing_scroll: self.scroll_manager.ongoing_scroll(),
|
||||||
placeholder_text: self.placeholder_text.clone(),
|
placeholder_text: self.placeholder_text.clone(),
|
||||||
is_focused: self.focus_handle.is_focused(cx),
|
is_focused: self.focus_handle.is_focused(cx),
|
||||||
current_line_highlight: self.current_line_highlight,
|
current_line_highlight: self
|
||||||
|
.current_line_highlight
|
||||||
|
.unwrap_or_else(|| EditorSettings::get_global(cx).current_line_highlight),
|
||||||
gutter_hovered: self.gutter_hovered,
|
gutter_hovered: self.gutter_hovered,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2082,7 +2083,10 @@ impl Editor {
|
|||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_current_line_highlight(&mut self, current_line_highlight: CurrentLineHighlight) {
|
pub fn set_current_line_highlight(
|
||||||
|
&mut self,
|
||||||
|
current_line_highlight: Option<CurrentLineHighlight>,
|
||||||
|
) {
|
||||||
self.current_line_highlight = current_line_highlight;
|
self.current_line_highlight = current_line_highlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10608,7 +10612,6 @@ impl Editor {
|
|||||||
let editor_settings = EditorSettings::get_global(cx);
|
let editor_settings = EditorSettings::get_global(cx);
|
||||||
self.scroll_manager.vertical_scroll_margin = editor_settings.vertical_scroll_margin;
|
self.scroll_manager.vertical_scroll_margin = editor_settings.vertical_scroll_margin;
|
||||||
self.show_breadcrumbs = editor_settings.toolbar.breadcrumbs;
|
self.show_breadcrumbs = editor_settings.toolbar.breadcrumbs;
|
||||||
self.current_line_highlight = editor_settings.current_line_highlight;
|
|
||||||
|
|
||||||
if self.mode == EditorMode::Full {
|
if self.mode == EditorMode::Full {
|
||||||
let inline_blame_enabled = ProjectSettings::get_global(cx).git.inline_blame_enabled();
|
let inline_blame_enabled = ProjectSettings::get_global(cx).git.inline_blame_enabled();
|
||||||
|
@ -10,7 +10,7 @@ use language::Buffer;
|
|||||||
use multi_buffer::{
|
use multi_buffer::{
|
||||||
Anchor, ExcerptRange, MultiBuffer, MultiBufferRow, MultiBufferSnapshot, ToPoint,
|
Anchor, ExcerptRange, MultiBuffer, MultiBufferRow, MultiBufferSnapshot, ToPoint,
|
||||||
};
|
};
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::SettingsStore;
|
||||||
use text::{BufferId, Point};
|
use text::{BufferId, Point};
|
||||||
use ui::{
|
use ui::{
|
||||||
div, ActiveTheme, Context as _, IntoElement, ParentElement, Styled, ViewContext, VisualContext,
|
div, ActiveTheme, Context as _, IntoElement, ParentElement, Styled, ViewContext, VisualContext,
|
||||||
@ -21,7 +21,7 @@ use crate::{
|
|||||||
editor_settings::CurrentLineHighlight,
|
editor_settings::CurrentLineHighlight,
|
||||||
git::{diff_hunk_to_display, DisplayDiffHunk},
|
git::{diff_hunk_to_display, DisplayDiffHunk},
|
||||||
hunk_status, hunks_for_selections, BlockDisposition, BlockId, BlockProperties, BlockStyle,
|
hunk_status, hunks_for_selections, BlockDisposition, BlockId, BlockProperties, BlockStyle,
|
||||||
DiffRowHighlight, Editor, EditorSettings, EditorSnapshot, ExpandAllHunkDiffs, RangeToAnchorExt,
|
DiffRowHighlight, Editor, EditorSnapshot, ExpandAllHunkDiffs, RangeToAnchorExt,
|
||||||
RevertSelectedHunks, ToDisplayPoint, ToggleHunkDiff,
|
RevertSelectedHunks, ToDisplayPoint, ToggleHunkDiff,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ fn editor_with_deleted_text(
|
|||||||
let subscription_editor = parent_editor.clone();
|
let subscription_editor = parent_editor.clone();
|
||||||
editor._subscriptions.extend([
|
editor._subscriptions.extend([
|
||||||
cx.on_blur(&editor.focus_handle, |editor, cx| {
|
cx.on_blur(&editor.focus_handle, |editor, cx| {
|
||||||
editor.set_current_line_highlight(CurrentLineHighlight::None);
|
editor.set_current_line_highlight(Some(CurrentLineHighlight::None));
|
||||||
editor.change_selections(None, cx, |s| {
|
editor.change_selections(None, cx, |s| {
|
||||||
s.try_cancel();
|
s.try_cancel();
|
||||||
});
|
});
|
||||||
@ -602,14 +602,14 @@ fn editor_with_deleted_text(
|
|||||||
{
|
{
|
||||||
parent_editor.read(cx).current_line_highlight
|
parent_editor.read(cx).current_line_highlight
|
||||||
} else {
|
} else {
|
||||||
EditorSettings::get_global(cx).current_line_highlight
|
None
|
||||||
};
|
};
|
||||||
editor.set_current_line_highlight(restored_highlight);
|
editor.set_current_line_highlight(restored_highlight);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}),
|
}),
|
||||||
cx.observe_global::<SettingsStore>(|editor, cx| {
|
cx.observe_global::<SettingsStore>(|editor, cx| {
|
||||||
if !editor.is_focused(cx) {
|
if !editor.is_focused(cx) {
|
||||||
editor.set_current_line_highlight(CurrentLineHighlight::None);
|
editor.set_current_line_highlight(Some(CurrentLineHighlight::None));
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user