editor mode -> display mode
Co-authored-by: Oleksiy Syvokon <oleksiy.syvokon@gmail.com>
This commit is contained in:
parent
57a0bb327d
commit
c6d0d75711
33 changed files with 255 additions and 225 deletions
|
@ -4,7 +4,7 @@ use acp_thread::{AcpThread, AgentThreadEntry};
|
|||
use agent_client_protocol::{PromptCapabilities, ToolCallId};
|
||||
use agent2::HistoryStore;
|
||||
use collections::HashMap;
|
||||
use editor::{Editor, EditorMode, MinimapVisibility};
|
||||
use editor::{Editor, EditorDisplayMode, MinimapVisibility};
|
||||
use gpui::{
|
||||
AnyEntity, App, AppContext as _, Entity, EntityId, EventEmitter, Focusable,
|
||||
TextStyleRefinement, WeakEntity, Window,
|
||||
|
@ -87,7 +87,7 @@ impl EntryViewState {
|
|||
self.prompt_capabilities.clone(),
|
||||
"Edit message - @ to include context",
|
||||
self.prevent_slash_commands,
|
||||
editor::EditorMode::AutoHeight {
|
||||
editor::EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: None,
|
||||
},
|
||||
|
@ -287,7 +287,7 @@ fn create_editor_diff(
|
|||
) -> Entity<Editor> {
|
||||
cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::Full {
|
||||
EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: false,
|
||||
show_active_line_background: false,
|
||||
sized_by_content: true,
|
||||
|
|
|
@ -10,9 +10,9 @@ use anyhow::{Context as _, Result, anyhow};
|
|||
use assistant_slash_commands::codeblock_fence_for_path;
|
||||
use collections::{HashMap, HashSet};
|
||||
use editor::{
|
||||
Addon, Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement,
|
||||
EditorEvent, EditorMode, EditorSnapshot, EditorStyle, ExcerptId, FoldPlaceholder, MultiBuffer,
|
||||
SemanticsProvider, ToOffset,
|
||||
Addon, Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor,
|
||||
EditorDisplayMode, EditorElement, EditorEvent, EditorSnapshot, EditorStyle, ExcerptId,
|
||||
FoldPlaceholder, MultiBuffer, SemanticsProvider, ToOffset,
|
||||
actions::Paste,
|
||||
display_map::{Crease, CreaseId, FoldId},
|
||||
};
|
||||
|
@ -90,7 +90,7 @@ impl MessageEditor {
|
|||
prompt_capabilities: Rc<Cell<acp::PromptCapabilities>>,
|
||||
placeholder: impl Into<Arc<str>>,
|
||||
prevent_slash_commands: bool,
|
||||
mode: EditorMode,
|
||||
mode: EditorDisplayMode,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
|
@ -1056,9 +1056,9 @@ impl MessageEditor {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn set_mode(&mut self, mode: EditorMode, cx: &mut Context<Self>) {
|
||||
pub fn set_display_mode(&mut self, mode: EditorDisplayMode, cx: &mut Context<Self>) {
|
||||
self.editor.update(cx, |editor, cx| {
|
||||
editor.set_mode(mode);
|
||||
editor.set_display_mode(mode);
|
||||
cx.notify()
|
||||
});
|
||||
}
|
||||
|
@ -1858,7 +1858,7 @@ mod tests {
|
|||
use agent_client_protocol as acp;
|
||||
use agent2::HistoryStore;
|
||||
use assistant_context::ContextStore;
|
||||
use editor::{AnchorRangeExt as _, Editor, EditorMode};
|
||||
use editor::{AnchorRangeExt as _, Editor, EditorDisplayMode};
|
||||
use fs::FakeFs;
|
||||
use futures::StreamExt as _;
|
||||
use gpui::{
|
||||
|
@ -1901,7 +1901,7 @@ mod tests {
|
|||
Default::default(),
|
||||
"Test",
|
||||
false,
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: None,
|
||||
},
|
||||
|
@ -2102,7 +2102,7 @@ mod tests {
|
|||
prompt_capabilities.clone(),
|
||||
"Test",
|
||||
false,
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
max_lines: None,
|
||||
min_lines: 1,
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@ use buffer_diff::BufferDiff;
|
|||
use client::zed_urls;
|
||||
use collections::{HashMap, HashSet};
|
||||
use editor::scroll::Autoscroll;
|
||||
use editor::{Editor, EditorEvent, EditorMode, MultiBuffer, PathKey, SelectionEffects};
|
||||
use editor::{Editor, EditorDisplayMode, EditorEvent, MultiBuffer, PathKey, SelectionEffects};
|
||||
use file_icons::FileIcons;
|
||||
use fs::Fs;
|
||||
use gpui::{
|
||||
|
@ -228,7 +228,7 @@ impl ThreadFeedbackState {
|
|||
|
||||
let editor = cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
editor::EditorMode::AutoHeight {
|
||||
editor::EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(4),
|
||||
},
|
||||
|
@ -321,7 +321,7 @@ impl AcpThreadView {
|
|||
prompt_capabilities.clone(),
|
||||
"Message the agent — @ to include context",
|
||||
prevent_slash_commands,
|
||||
editor::EditorMode::AutoHeight {
|
||||
editor::EditorDisplayMode::AutoHeight {
|
||||
min_lines: MIN_EDITOR_LINES,
|
||||
max_lines: Some(MAX_EDITOR_LINES),
|
||||
},
|
||||
|
@ -673,8 +673,8 @@ impl AcpThreadView {
|
|||
self.editor_expanded = is_expanded;
|
||||
self.message_editor.update(cx, |editor, cx| {
|
||||
if is_expanded {
|
||||
editor.set_mode(
|
||||
EditorMode::Full {
|
||||
editor.set_display_mode(
|
||||
EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: false,
|
||||
show_active_line_background: false,
|
||||
sized_by_content: false,
|
||||
|
@ -682,8 +682,8 @@ impl AcpThreadView {
|
|||
cx,
|
||||
)
|
||||
} else {
|
||||
editor.set_mode(
|
||||
EditorMode::AutoHeight {
|
||||
editor.set_display_mode(
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: MIN_EDITOR_LINES,
|
||||
max_lines: Some(MAX_EDITOR_LINES),
|
||||
},
|
||||
|
|
|
@ -1723,7 +1723,7 @@ impl ActiveThread {
|
|||
|
||||
let editor = cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
editor::EditorMode::AutoHeight {
|
||||
editor::EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(4),
|
||||
},
|
||||
|
|
|
@ -1046,7 +1046,7 @@ impl ToolbarItemView for AgentDiffToolbar {
|
|||
}
|
||||
|
||||
if let Some(editor) = item.act_as::<Editor>(cx)
|
||||
&& editor.read(cx).mode().is_full()
|
||||
&& editor.read(cx).display_mode().is_full()
|
||||
{
|
||||
let agent_diff = AgentDiff::global(cx);
|
||||
|
||||
|
@ -1549,7 +1549,7 @@ impl AgentDiff {
|
|||
}
|
||||
|
||||
fn full_editor_buffer(editor: &Editor, cx: &App) -> Option<WeakEntity<Buffer>> {
|
||||
if editor.mode().is_full() {
|
||||
if editor.display_mode().is_full() {
|
||||
editor
|
||||
.buffer()
|
||||
.read(cx)
|
||||
|
|
|
@ -1244,7 +1244,7 @@ mod tests {
|
|||
let editor = workspace.update_in(&mut cx, |workspace, window, cx| {
|
||||
let editor = cx.new(|cx| {
|
||||
Editor::new(
|
||||
editor::EditorMode::full(),
|
||||
editor::EditorDisplayMode::full(),
|
||||
multi_buffer::MultiBuffer::build_simple("", cx),
|
||||
None,
|
||||
window,
|
||||
|
|
|
@ -16,7 +16,8 @@ use db::kvp::Dismissable;
|
|||
use editor::actions::Paste;
|
||||
use editor::display_map::EditorMargins;
|
||||
use editor::{
|
||||
ContextMenuOptions, Editor, EditorElement, EditorEvent, EditorMode, EditorStyle, MultiBuffer,
|
||||
ContextMenuOptions, Editor, EditorDisplayMode, EditorElement, EditorEvent, EditorStyle,
|
||||
MultiBuffer,
|
||||
actions::{MoveDown, MoveUp},
|
||||
};
|
||||
use feature_flags::{FeatureFlagAppExt as _, ZedProFeatureFlag};
|
||||
|
@ -869,7 +870,7 @@ impl PromptEditor<BufferCodegen> {
|
|||
|
||||
let prompt_editor = cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(Self::MAX_LINES as usize),
|
||||
},
|
||||
|
@ -1048,7 +1049,7 @@ impl PromptEditor<TerminalCodegen> {
|
|||
|
||||
let prompt_editor = cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(Self::MAX_LINES as usize),
|
||||
},
|
||||
|
|
|
@ -22,8 +22,8 @@ use collections::{HashMap, HashSet};
|
|||
use editor::actions::{MoveUp, Paste};
|
||||
use editor::display_map::CreaseId;
|
||||
use editor::{
|
||||
Addon, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement,
|
||||
EditorEvent, EditorMode, EditorStyle, MultiBuffer,
|
||||
Addon, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorDisplayMode,
|
||||
EditorElement, EditorEvent, EditorStyle, MultiBuffer,
|
||||
};
|
||||
use file_icons::FileIcons;
|
||||
use fs::Fs;
|
||||
|
@ -127,7 +127,7 @@ pub(crate) fn create_editor(
|
|||
};
|
||||
|
||||
let mut editor = Editor::new(
|
||||
editor::EditorMode::AutoHeight {
|
||||
editor::EditorDisplayMode::AutoHeight {
|
||||
min_lines,
|
||||
max_lines,
|
||||
},
|
||||
|
@ -312,13 +312,13 @@ impl MessageEditor {
|
|||
self.editor_is_expanded = is_expanded;
|
||||
self.editor.update(cx, |editor, _| {
|
||||
if self.editor_is_expanded {
|
||||
editor.set_mode(EditorMode::Full {
|
||||
editor.set_display_mode(EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: false,
|
||||
show_active_line_background: false,
|
||||
sized_by_content: false,
|
||||
})
|
||||
} else {
|
||||
editor.set_mode(EditorMode::AutoHeight {
|
||||
editor.set_display_mode(EditorDisplayMode::AutoHeight {
|
||||
min_lines: MIN_EDITOR_LINES,
|
||||
max_lines: Some(MAX_EDITOR_LINES),
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ use assistant_tool::{
|
|||
AnyToolCard, Tool, ToolCard, ToolResult, ToolResultContent, ToolResultOutput, ToolUseStatus,
|
||||
};
|
||||
use buffer_diff::{BufferDiff, BufferDiffSnapshot};
|
||||
use editor::{Editor, EditorMode, MinimapVisibility, MultiBuffer, PathKey};
|
||||
use editor::{Editor, EditorDisplayMode, MinimapVisibility, MultiBuffer, PathKey};
|
||||
use futures::StreamExt;
|
||||
use gpui::{
|
||||
Animation, AnimationExt, AnyWindowHandle, App, AppContext, AsyncApp, Entity, Task,
|
||||
|
@ -582,7 +582,7 @@ impl EditFileToolCard {
|
|||
|
||||
let editor = cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::Full {
|
||||
EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: false,
|
||||
show_active_line_background: false,
|
||||
sized_by_content: true,
|
||||
|
|
|
@ -14,7 +14,7 @@ use dap::{
|
|||
},
|
||||
};
|
||||
use editor::{
|
||||
ActiveDebugLine, Editor, EditorMode, MultiBuffer,
|
||||
ActiveDebugLine, Editor, EditorDisplayMode, MultiBuffer,
|
||||
actions::{self},
|
||||
};
|
||||
use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext};
|
||||
|
@ -1121,7 +1121,7 @@ async fn test_send_breakpoints_when_editor_has_been_saved(
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -1290,7 +1290,7 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
|
|||
|
||||
let (first_editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(first, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -1300,7 +1300,7 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
|
|||
|
||||
let (second_editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(second, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -1513,7 +1513,7 @@ async fn test_active_debug_line_setting(executor: BackgroundExecutor, cx: &mut T
|
|||
|
||||
let (main_editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(main_buffer, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -1523,7 +1523,7 @@ async fn test_active_debug_line_setting(executor: BackgroundExecutor, cx: &mut T
|
|||
|
||||
let (second_editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(second_buffer, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use dap::{Scope, StackFrame, Variable, requests::Variables};
|
||||
use editor::{Editor, EditorMode, MultiBuffer};
|
||||
use editor::{Editor, EditorDisplayMode, MultiBuffer};
|
||||
use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext};
|
||||
use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_python, tree_sitter_rust};
|
||||
use project::{FakeFs, Project};
|
||||
|
@ -226,7 +226,7 @@ fn main() {
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project),
|
||||
window,
|
||||
|
@ -1595,7 +1595,7 @@ def process_data(untyped_param, typed_param: int, another_typed: str):
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project),
|
||||
window,
|
||||
|
@ -2093,7 +2093,7 @@ async fn test_inline_values_util(
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project),
|
||||
window,
|
||||
|
|
|
@ -496,7 +496,7 @@ pub enum SelectMode {
|
|||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub enum EditorMode {
|
||||
pub enum EditorDisplayMode {
|
||||
SingleLine,
|
||||
AutoHeight {
|
||||
min_lines: usize,
|
||||
|
@ -515,7 +515,7 @@ pub enum EditorMode {
|
|||
},
|
||||
}
|
||||
|
||||
impl EditorMode {
|
||||
impl EditorDisplayMode {
|
||||
pub fn full() -> Self {
|
||||
Self::Full {
|
||||
scale_ui_elements_with_buffer_font_size: true,
|
||||
|
@ -759,7 +759,7 @@ pub enum MinimapVisibility {
|
|||
}
|
||||
|
||||
impl MinimapVisibility {
|
||||
fn for_mode(mode: &EditorMode, cx: &App) -> Self {
|
||||
fn for_display_mode(mode: &EditorDisplayMode, cx: &App) -> Self {
|
||||
if mode.is_full() {
|
||||
Self::Enabled {
|
||||
setting_configuration: EditorSettings::get_global(cx).minimap.minimap_enabled(),
|
||||
|
@ -1046,7 +1046,7 @@ pub struct Editor {
|
|||
show_cursor_names: bool,
|
||||
hovered_cursors: HashMap<HoveredCursor, Task<()>>,
|
||||
pub show_local_selections: bool,
|
||||
mode: EditorMode,
|
||||
display_mode: EditorDisplayMode,
|
||||
show_breadcrumbs: bool,
|
||||
show_gutter: bool,
|
||||
show_scrollbars: ScrollbarAxes,
|
||||
|
@ -1236,7 +1236,7 @@ impl NextScrollCursorCenterTopBottom {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct EditorSnapshot {
|
||||
pub mode: EditorMode,
|
||||
pub display_mode: EditorDisplayMode,
|
||||
show_gutter: bool,
|
||||
show_line_numbers: Option<bool>,
|
||||
show_git_diff_gutter: Option<bool>,
|
||||
|
@ -1704,13 +1704,13 @@ impl Editor {
|
|||
pub fn single_line(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let buffer = cx.new(|cx| Buffer::local("", cx));
|
||||
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::SingleLine, buffer, None, window, cx)
|
||||
Self::new(EditorDisplayMode::SingleLine, buffer, None, window, cx)
|
||||
}
|
||||
|
||||
pub fn multi_line(window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let buffer = cx.new(|cx| Buffer::local("", cx));
|
||||
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::full(), buffer, None, window, cx)
|
||||
Self::new(EditorDisplayMode::full(), buffer, None, window, cx)
|
||||
}
|
||||
|
||||
pub fn auto_height(
|
||||
|
@ -1722,7 +1722,7 @@ impl Editor {
|
|||
let buffer = cx.new(|cx| Buffer::local("", cx));
|
||||
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines,
|
||||
max_lines: Some(max_lines),
|
||||
},
|
||||
|
@ -1743,7 +1743,7 @@ impl Editor {
|
|||
let buffer = cx.new(|cx| Buffer::local("", cx));
|
||||
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines,
|
||||
max_lines: None,
|
||||
},
|
||||
|
@ -1761,7 +1761,7 @@ impl Editor {
|
|||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
Self::new(EditorMode::full(), buffer, project, window, cx)
|
||||
Self::new(EditorDisplayMode::full(), buffer, project, window, cx)
|
||||
}
|
||||
|
||||
pub fn for_multibuffer(
|
||||
|
@ -1770,12 +1770,12 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
Self::new(EditorMode::full(), buffer, project, window, cx)
|
||||
Self::new(EditorDisplayMode::full(), buffer, project, window, cx)
|
||||
}
|
||||
|
||||
pub fn clone(&self, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||
let mut clone = Self::new(
|
||||
self.mode.clone(),
|
||||
self.display_mode.clone(),
|
||||
self.buffer.clone(),
|
||||
self.project.clone(),
|
||||
window,
|
||||
|
@ -1796,7 +1796,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn new(
|
||||
mode: EditorMode,
|
||||
mode: EditorDisplayMode,
|
||||
buffer: Entity<MultiBuffer>,
|
||||
project: Option<Entity<Project>>,
|
||||
window: &mut Window,
|
||||
|
@ -1806,7 +1806,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
fn new_internal(
|
||||
mode: EditorMode,
|
||||
mode: EditorDisplayMode,
|
||||
buffer: Entity<MultiBuffer>,
|
||||
project: Option<Entity<Project>>,
|
||||
display_map: Option<Entity<DisplayMap>>,
|
||||
|
@ -1888,8 +1888,8 @@ impl Editor {
|
|||
blink_manager
|
||||
});
|
||||
|
||||
let soft_wrap_mode_override =
|
||||
matches!(mode, EditorMode::SingleLine).then(|| language_settings::SoftWrap::None);
|
||||
let soft_wrap_mode_override = matches!(mode, EditorDisplayMode::SingleLine)
|
||||
.then(|| language_settings::SoftWrap::None);
|
||||
|
||||
let mut project_subscriptions = Vec::new();
|
||||
if full_mode && let Some(project) = project.as_ref() {
|
||||
|
@ -2068,15 +2068,19 @@ impl Editor {
|
|||
.detach();
|
||||
}
|
||||
|
||||
let show_indent_guides =
|
||||
if matches!(mode, EditorMode::SingleLine | EditorMode::Minimap { .. }) {
|
||||
Some(false)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let show_indent_guides = if matches!(
|
||||
mode,
|
||||
EditorDisplayMode::SingleLine | EditorDisplayMode::Minimap { .. }
|
||||
) {
|
||||
Some(false)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let breakpoint_store = match (&mode, project.as_ref()) {
|
||||
(EditorMode::Full { .. }, Some(project)) => Some(project.read(cx).breakpoint_store()),
|
||||
(EditorDisplayMode::Full { .. }, Some(project)) => {
|
||||
Some(project.read(cx).breakpoint_store())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
@ -2132,8 +2136,8 @@ impl Editor {
|
|||
horizontal: full_mode,
|
||||
vertical: full_mode,
|
||||
},
|
||||
minimap_visibility: MinimapVisibility::for_mode(&mode, cx),
|
||||
offset_content: !matches!(mode, EditorMode::SingleLine),
|
||||
minimap_visibility: MinimapVisibility::for_display_mode(&mode, cx),
|
||||
offset_content: !matches!(mode, EditorDisplayMode::SingleLine),
|
||||
show_breadcrumbs: EditorSettings::get_global(cx).toolbar.breadcrumbs,
|
||||
show_gutter: full_mode,
|
||||
show_line_numbers: (!full_mode).then_some(false),
|
||||
|
@ -2289,7 +2293,7 @@ impl Editor {
|
|||
.hide_mouse
|
||||
.unwrap_or_default(),
|
||||
change_list: ChangeList::new(),
|
||||
mode,
|
||||
display_mode: mode,
|
||||
selection_drag_state: SelectionDragState::None,
|
||||
folding_newlines: Task::ready(()),
|
||||
default_editor_mode: vim_mode_setting::EditorMode::default(),
|
||||
|
@ -2418,7 +2422,7 @@ impl Editor {
|
|||
editor.update_lsp_data(false, None, window, cx);
|
||||
}
|
||||
|
||||
if editor.mode.is_full() {
|
||||
if editor.display_mode.is_full() {
|
||||
editor.report_editor_event(ReportEditorEvent::EditorOpened, None, cx);
|
||||
}
|
||||
|
||||
|
@ -2487,11 +2491,11 @@ impl Editor {
|
|||
) -> KeyContext {
|
||||
let mut key_context = KeyContext::new_with_defaults();
|
||||
key_context.add("Editor");
|
||||
let mode = match self.mode {
|
||||
EditorMode::SingleLine => "single_line",
|
||||
EditorMode::AutoHeight { .. } => "auto_height",
|
||||
EditorMode::Minimap { .. } => "minimap",
|
||||
EditorMode::Full { .. } => "full",
|
||||
let mode = match self.display_mode {
|
||||
EditorDisplayMode::SingleLine => "single_line",
|
||||
EditorDisplayMode::AutoHeight { .. } => "auto_height",
|
||||
EditorDisplayMode::Minimap { .. } => "minimap",
|
||||
EditorDisplayMode::Full { .. } => "full",
|
||||
};
|
||||
|
||||
if EditorSettings::jupyter_enabled(cx) {
|
||||
|
@ -2755,7 +2759,7 @@ impl Editor {
|
|||
.flatten();
|
||||
|
||||
EditorSnapshot {
|
||||
mode: self.mode.clone(),
|
||||
display_mode: self.display_mode.clone(),
|
||||
show_gutter: self.show_gutter,
|
||||
show_line_numbers: self.show_line_numbers,
|
||||
show_git_diff_gutter: self.show_git_diff_gutter,
|
||||
|
@ -2792,12 +2796,12 @@ impl Editor {
|
|||
.excerpt_containing(self.selections.newest_anchor().head(), cx)
|
||||
}
|
||||
|
||||
pub fn mode(&self) -> &EditorMode {
|
||||
&self.mode
|
||||
pub fn display_mode(&self) -> &EditorDisplayMode {
|
||||
&self.display_mode
|
||||
}
|
||||
|
||||
pub fn set_mode(&mut self, mode: EditorMode) {
|
||||
self.mode = mode;
|
||||
pub fn set_display_mode(&mut self, mode: EditorDisplayMode) {
|
||||
self.display_mode = mode;
|
||||
}
|
||||
|
||||
pub fn collaboration_hub(&self) -> Option<&dyn CollaborationHub> {
|
||||
|
@ -3237,7 +3241,7 @@ impl Editor {
|
|||
use text::ToOffset as _;
|
||||
use text::ToPoint as _;
|
||||
|
||||
if self.mode.is_minimap()
|
||||
if self.display_mode.is_minimap()
|
||||
|| WorkspaceSettings::get(None, cx).restore_on_startup == RestoreOnStartupBehavior::None
|
||||
{
|
||||
return;
|
||||
|
@ -3920,7 +3924,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if self.mode.is_full()
|
||||
if self.display_mode.is_full()
|
||||
&& self.change_selections(Default::default(), window, cx, |s| s.try_cancel())
|
||||
{
|
||||
return;
|
||||
|
@ -3963,7 +3967,9 @@ impl Editor {
|
|||
return true;
|
||||
}
|
||||
|
||||
if self.mode.is_full() && matches!(self.active_diagnostics, ActiveDiagnostic::Group(_)) {
|
||||
if self.display_mode.is_full()
|
||||
&& matches!(self.active_diagnostics, ActiveDiagnostic::Group(_))
|
||||
{
|
||||
self.dismiss_diagnostics(cx);
|
||||
return true;
|
||||
}
|
||||
|
@ -5177,7 +5183,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
fn refresh_inlay_hints(&mut self, reason: InlayHintRefreshReason, cx: &mut Context<Self>) {
|
||||
if self.semantics_provider.is_none() || !self.mode.is_full() {
|
||||
if self.semantics_provider.is_none() || !self.display_mode.is_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6854,7 +6860,7 @@ impl Editor {
|
|||
&mut self,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> Option<(String, Range<Anchor>)> {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
return None;
|
||||
}
|
||||
if !EditorSettings::get_global(cx).selection_highlight {
|
||||
|
@ -6953,7 +6959,7 @@ impl Editor {
|
|||
fn refresh_single_line_folds(&mut self, window: &mut Window, cx: &mut Context<Editor>) {
|
||||
struct NewlineFold;
|
||||
let type_id = std::any::TypeId::of::<NewlineFold>();
|
||||
if !self.mode.is_single_line() {
|
||||
if !self.display_mode.is_single_line() {
|
||||
return;
|
||||
}
|
||||
let snapshot = self.snapshot(window, cx);
|
||||
|
@ -7179,7 +7185,7 @@ impl Editor {
|
|||
buffer_position: language::Anchor,
|
||||
cx: &App,
|
||||
) -> EditPredictionSettings {
|
||||
if !self.mode.is_full()
|
||||
if !self.display_mode.is_full()
|
||||
|| !self.show_edit_predictions_override.unwrap_or(true)
|
||||
|| self.edit_predictions_disabled_in_scope(buffer, buffer_position, cx)
|
||||
{
|
||||
|
@ -8518,7 +8524,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<(AnyElement, gpui::Point<Pixels>)> {
|
||||
if self.mode().is_minimap() {
|
||||
if self.display_mode().is_minimap() {
|
||||
return None;
|
||||
}
|
||||
let active_edit_prediction = self.active_edit_prediction.as_ref()?;
|
||||
|
@ -9955,7 +9961,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn backtab(&mut self, _: &Backtab, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -9968,7 +9974,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn tab(&mut self, _: &Tab, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -10091,7 +10097,7 @@ impl Editor {
|
|||
if self.read_only(cx) {
|
||||
return;
|
||||
}
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -10199,7 +10205,7 @@ impl Editor {
|
|||
if self.read_only(cx) {
|
||||
return;
|
||||
}
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -10276,7 +10282,7 @@ impl Editor {
|
|||
if self.read_only(cx) {
|
||||
return;
|
||||
}
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -11521,7 +11527,7 @@ impl Editor {
|
|||
|
||||
pub fn move_line_up(&mut self, _: &MoveLineUp, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -11632,7 +11638,7 @@ impl Editor {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -11784,7 +11790,7 @@ impl Editor {
|
|||
|
||||
pub fn rewrap(&mut self, _: &Rewrap, _: &mut Window, cx: &mut Context<Self>) {
|
||||
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -12495,7 +12501,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -12538,7 +12544,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -12575,7 +12581,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -12673,7 +12679,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -12723,7 +12729,7 @@ impl Editor {
|
|||
pub fn move_down(&mut self, _: &MoveDown, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.take_rename(true, window, cx);
|
||||
|
||||
if self.mode.is_single_line() {
|
||||
if self.display_mode.is_single_line() {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -12797,7 +12803,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13281,7 +13287,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13302,7 +13308,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13323,7 +13329,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13344,7 +13350,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13365,7 +13371,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13390,7 +13396,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13415,7 +13421,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13440,7 +13446,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13465,7 +13471,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13486,7 +13492,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13507,7 +13513,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13528,7 +13534,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13549,7 +13555,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -13574,7 +13580,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn move_to_end(&mut self, _: &MoveToEnd, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
@ -14623,7 +14629,7 @@ impl Editor {
|
|||
let advance_downwards = action.advance_downwards
|
||||
&& selections_on_single_row
|
||||
&& !selections_selecting
|
||||
&& !matches!(this.mode, EditorMode::SingleLine);
|
||||
&& !matches!(this.display_mode, EditorDisplayMode::SingleLine);
|
||||
|
||||
if advance_downwards {
|
||||
let snapshot = this.buffer.read(cx).snapshot(cx);
|
||||
|
@ -16948,7 +16954,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn diagnostics_enabled(&self) -> bool {
|
||||
self.diagnostics_enabled && self.mode.is_full()
|
||||
self.diagnostics_enabled && self.display_mode.is_full()
|
||||
}
|
||||
|
||||
pub fn inline_diagnostics_enabled(&self) -> bool {
|
||||
|
@ -17108,7 +17114,7 @@ impl Editor {
|
|||
window: &Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<()> {
|
||||
if !self.mode().is_full() {
|
||||
if !self.display_mode().is_full() {
|
||||
return None;
|
||||
}
|
||||
let pull_diagnostics_settings = ProjectSettings::get_global(cx)
|
||||
|
@ -18390,7 +18396,7 @@ impl Editor {
|
|||
const MINIMAP_FONT_WEIGHT: gpui::FontWeight = gpui::FontWeight::BLACK;
|
||||
|
||||
let mut minimap = Editor::new_internal(
|
||||
EditorMode::Minimap {
|
||||
EditorDisplayMode::Minimap {
|
||||
parent: cx.weak_entity(),
|
||||
},
|
||||
self.buffer.clone(),
|
||||
|
@ -18492,7 +18498,7 @@ impl Editor {
|
|||
// We intentionally do not inform the display map about the minimap style
|
||||
// so that wrapping is not recalculated and stays consistent for the editor
|
||||
// and its linked minimap.
|
||||
if !self.mode.is_minimap() {
|
||||
if !self.display_mode.is_minimap() {
|
||||
let rem_size = window.rem_size();
|
||||
self.display_map.update(cx, |map, cx| {
|
||||
map.set_font(
|
||||
|
@ -19038,7 +19044,9 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn render_git_blame_gutter(&self, cx: &App) -> bool {
|
||||
!self.mode().is_minimap() && self.show_git_blame_gutter && self.has_blame_entries(cx)
|
||||
!self.display_mode().is_minimap()
|
||||
&& self.show_git_blame_gutter
|
||||
&& self.has_blame_entries(cx)
|
||||
}
|
||||
|
||||
pub fn render_git_blame_inline(&self, window: &Window, cx: &App) -> bool {
|
||||
|
@ -20309,9 +20317,9 @@ impl Editor {
|
|||
|
||||
let project_settings = ProjectSettings::get_global(cx);
|
||||
self.serialize_dirty_buffers =
|
||||
!self.mode.is_minimap() && project_settings.session.restore_unsaved_buffers;
|
||||
!self.display_mode.is_minimap() && project_settings.session.restore_unsaved_buffers;
|
||||
|
||||
if self.mode.is_full() {
|
||||
if self.display_mode.is_full() {
|
||||
let show_inline_diagnostics = project_settings.diagnostics.inline.enabled;
|
||||
let inline_blame_enabled = project_settings.git.inline_blame_enabled();
|
||||
if self.show_inline_diagnostics != show_inline_diagnostics {
|
||||
|
@ -20329,7 +20337,7 @@ impl Editor {
|
|||
!= minimap_settings.minimap_enabled()
|
||||
{
|
||||
self.set_minimap_visibility(
|
||||
MinimapVisibility::for_mode(self.mode(), cx),
|
||||
MinimapVisibility::for_display_mode(self.display_mode(), cx),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
|
@ -21162,7 +21170,7 @@ impl Editor {
|
|||
}
|
||||
|
||||
pub fn register_addon<T: Addon>(&mut self, instance: T) {
|
||||
if self.mode.is_minimap() {
|
||||
if self.display_mode.is_minimap() {
|
||||
return;
|
||||
}
|
||||
self.addons
|
||||
|
@ -21215,7 +21223,7 @@ impl Editor {
|
|||
cx: &mut Context<Editor>,
|
||||
) {
|
||||
if self.is_singleton(cx)
|
||||
&& !self.mode.is_minimap()
|
||||
&& !self.display_mode.is_minimap()
|
||||
&& WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None
|
||||
{
|
||||
let buffer_snapshot = OnceCell::new();
|
||||
|
@ -22946,8 +22954,8 @@ impl Render for Editor {
|
|||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let settings = ThemeSettings::get_global(cx);
|
||||
|
||||
let mut text_style = match self.mode {
|
||||
EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle {
|
||||
let mut text_style = match self.display_mode {
|
||||
EditorDisplayMode::SingleLine | EditorDisplayMode::AutoHeight { .. } => TextStyle {
|
||||
color: cx.theme().colors().editor_foreground,
|
||||
font_family: settings.ui_font.family.clone(),
|
||||
font_features: settings.ui_font.features.clone(),
|
||||
|
@ -22957,7 +22965,7 @@ impl Render for Editor {
|
|||
line_height: relative(settings.buffer_line_height.value()),
|
||||
..Default::default()
|
||||
},
|
||||
EditorMode::Full { .. } | EditorMode::Minimap { .. } => TextStyle {
|
||||
EditorDisplayMode::Full { .. } | EditorDisplayMode::Minimap { .. } => TextStyle {
|
||||
color: cx.theme().colors().editor_foreground,
|
||||
font_family: settings.buffer_font.family.clone(),
|
||||
font_features: settings.buffer_font.features.clone(),
|
||||
|
@ -22972,11 +22980,11 @@ impl Render for Editor {
|
|||
text_style.refine(text_style_refinement)
|
||||
}
|
||||
|
||||
let background = match self.mode {
|
||||
EditorMode::SingleLine => cx.theme().system().transparent,
|
||||
EditorMode::AutoHeight { .. } => cx.theme().system().transparent,
|
||||
EditorMode::Full { .. } => cx.theme().colors().editor_background,
|
||||
EditorMode::Minimap { .. } => cx.theme().colors().editor_background.opacity(0.7),
|
||||
let background = match self.display_mode {
|
||||
EditorDisplayMode::SingleLine => cx.theme().system().transparent,
|
||||
EditorDisplayMode::AutoHeight { .. } => cx.theme().system().transparent,
|
||||
EditorDisplayMode::Full { .. } => cx.theme().colors().editor_background,
|
||||
EditorDisplayMode::Minimap { .. } => cx.theme().colors().editor_background.opacity(0.7),
|
||||
};
|
||||
|
||||
EditorElement::new(
|
||||
|
@ -23661,7 +23669,7 @@ impl BreakpointPromptEditor {
|
|||
|
||||
let prompt = cx.new(|cx| {
|
||||
let mut prompt = Editor::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(Self::MAX_LINES as usize),
|
||||
},
|
||||
|
|
|
@ -10075,7 +10075,7 @@ async fn test_multibuffer_format_during_save(cx: &mut TestAppContext) {
|
|||
});
|
||||
let multi_buffer_editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -10252,7 +10252,7 @@ async fn test_autosave_with_dirty_buffers(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -12646,7 +12646,7 @@ async fn test_completion_in_multibuffer_with_replace_range(cx: &mut TestAppConte
|
|||
.update(cx, |_, window, cx| {
|
||||
cx.new(|cx| {
|
||||
Editor::new(
|
||||
EditorMode::Full {
|
||||
EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: false,
|
||||
show_active_line_background: false,
|
||||
sized_by_content: false,
|
||||
|
@ -17433,7 +17433,7 @@ async fn test_multibuffer_in_navigation_history(cx: &mut TestAppContext) {
|
|||
let cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
|
||||
let multi_buffer_editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -17900,8 +17900,9 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut TestAppContext) {
|
|||
multibuffer
|
||||
});
|
||||
|
||||
let editor =
|
||||
cx.add_window(|window, cx| Editor::new(EditorMode::full(), multi_buffer, None, window, cx));
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
Editor::new(EditorDisplayMode::full(), multi_buffer, None, window, cx)
|
||||
});
|
||||
editor
|
||||
.update(cx, |editor, _window, cx| {
|
||||
for (buffer, diff_base) in [
|
||||
|
@ -18011,8 +18012,9 @@ async fn test_expand_diff_hunk_at_excerpt_boundary(cx: &mut TestAppContext) {
|
|||
multibuffer
|
||||
});
|
||||
|
||||
let editor =
|
||||
cx.add_window(|window, cx| Editor::new(EditorMode::full(), multi_buffer, None, window, cx));
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
Editor::new(EditorDisplayMode::full(), multi_buffer, None, window, cx)
|
||||
});
|
||||
editor
|
||||
.update(cx, |editor, _window, cx| {
|
||||
let diff = cx.new(|cx| BufferDiff::new_with_base_text(base, &buffer, cx));
|
||||
|
@ -19693,7 +19695,13 @@ async fn test_display_diff_hunks(cx: &mut TestAppContext) {
|
|||
});
|
||||
|
||||
let editor = cx.add_window(|window, cx| {
|
||||
Editor::new(EditorMode::full(), multibuffer, Some(project), window, cx)
|
||||
Editor::new(
|
||||
EditorDisplayMode::full(),
|
||||
multibuffer,
|
||||
Some(project),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
cx.run_until_parked();
|
||||
|
||||
|
@ -20205,7 +20213,7 @@ async fn test_find_enclosing_node_with_task(cx: &mut TestAppContext) {
|
|||
|
||||
let editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -20332,7 +20340,7 @@ async fn test_folding_buffers(cx: &mut TestAppContext) {
|
|||
});
|
||||
let multi_buffer_editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer.clone(),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -20489,7 +20497,7 @@ async fn test_folding_buffers_with_one_excerpt(cx: &mut TestAppContext) {
|
|||
|
||||
let multi_buffer_editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -20607,7 +20615,7 @@ async fn test_folding_buffer_when_multibuffer_has_only_one_excerpt(cx: &mut Test
|
|||
});
|
||||
let multi_buffer_editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -20659,7 +20667,13 @@ async fn test_multi_buffer_navigation_with_folded_buffers(cx: &mut TestAppContex
|
|||
],
|
||||
cx,
|
||||
);
|
||||
let mut editor = Editor::new(EditorMode::full(), multi_buffer.clone(), None, window, cx);
|
||||
let mut editor = Editor::new(
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer.clone(),
|
||||
None,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
|
||||
let buffer_ids = multi_buffer.read(cx).excerpt_buffer_ids();
|
||||
// fold all but the second buffer, so that we test navigating between two
|
||||
|
@ -20971,7 +20985,7 @@ async fn assert_highlighted_edits(
|
|||
) {
|
||||
let window = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple(text, cx);
|
||||
Editor::new(EditorMode::full(), buffer, None, window, cx)
|
||||
Editor::new(EditorDisplayMode::full(), buffer, None, window, cx)
|
||||
});
|
||||
let cx = &mut VisualTestContext::from_window(*window, cx);
|
||||
|
||||
|
@ -21131,7 +21145,7 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -21245,7 +21259,7 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -21415,7 +21429,7 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
|
|||
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
MultiBuffer::build_from_buffer(buffer, cx),
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
@ -22373,7 +22387,7 @@ async fn test_hide_mouse_context_menu_on_modal_opened(cx: &mut TestAppContext) {
|
|||
let cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
|
||||
let editor = cx.new_window_entity(|window, cx| {
|
||||
Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
buffer,
|
||||
Some(project.clone()),
|
||||
window,
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter,
|
||||
ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId,
|
||||
DisplayDiffHunk, DisplayPoint, DisplayRow, DocumentHighlightRead, DocumentHighlightWrite,
|
||||
EditDisplayMode, EditPrediction, Editor, EditorMode, EditorSettings, EditorSnapshot,
|
||||
EditDisplayMode, EditPrediction, Editor, EditorDisplayMode, EditorSettings, EditorSnapshot,
|
||||
EditorStyle, FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp,
|
||||
HandleInput, HoveredCursor, InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp,
|
||||
MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown,
|
||||
|
@ -1816,7 +1816,7 @@ impl EditorElement {
|
|||
}
|
||||
}
|
||||
|
||||
if !snapshot.mode.is_full()
|
||||
if !snapshot.display_mode.is_full()
|
||||
|| minimap_width.is_zero()
|
||||
|| matches!(
|
||||
minimap_settings.show,
|
||||
|
@ -3212,7 +3212,7 @@ impl EditorElement {
|
|||
cx: &mut App,
|
||||
) -> Vec<Option<AnyElement>> {
|
||||
let include_fold_statuses = EditorSettings::get_global(cx).gutter.folds
|
||||
&& snapshot.mode.is_full()
|
||||
&& snapshot.display_mode.is_full()
|
||||
&& self.editor.read(cx).is_singleton(cx);
|
||||
if include_fold_statuses {
|
||||
row_infos
|
||||
|
@ -3314,7 +3314,7 @@ impl EditorElement {
|
|||
style,
|
||||
MAX_LINE_LEN,
|
||||
rows.len(),
|
||||
&snapshot.mode,
|
||||
&snapshot.display_mode,
|
||||
editor_width,
|
||||
is_row_soft_wrapped,
|
||||
window,
|
||||
|
@ -5282,14 +5282,14 @@ impl EditorElement {
|
|||
|
||||
if matches!(
|
||||
layout.mode,
|
||||
EditorMode::Full { .. } | EditorMode::Minimap { .. }
|
||||
EditorDisplayMode::Full { .. } | EditorDisplayMode::Minimap { .. }
|
||||
) {
|
||||
let show_active_line_background = match layout.mode {
|
||||
EditorMode::Full {
|
||||
EditorDisplayMode::Full {
|
||||
show_active_line_background,
|
||||
..
|
||||
} => show_active_line_background,
|
||||
EditorMode::Minimap { .. } => true,
|
||||
EditorDisplayMode::Minimap { .. } => true,
|
||||
_ => false,
|
||||
};
|
||||
let mut active_rows = layout.active_rows.iter().peekable();
|
||||
|
@ -7311,7 +7311,7 @@ impl LineWithInvisibles {
|
|||
editor_style: &EditorStyle,
|
||||
max_line_len: usize,
|
||||
max_line_count: usize,
|
||||
editor_mode: &EditorMode,
|
||||
editor_mode: &EditorDisplayMode,
|
||||
text_width: Pixels,
|
||||
is_row_soft_wrapped: impl Copy + Fn(usize) -> bool,
|
||||
window: &mut Window,
|
||||
|
@ -7839,12 +7839,12 @@ impl EditorElement {
|
|||
///
|
||||
/// This allows UI elements to scale based on the `buffer_font_size`.
|
||||
fn rem_size(&self, cx: &mut App) -> Option<Pixels> {
|
||||
match self.editor.read(cx).mode {
|
||||
EditorMode::Full {
|
||||
match self.editor.read(cx).display_mode {
|
||||
EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: true,
|
||||
..
|
||||
}
|
||||
| EditorMode::Minimap { .. } => {
|
||||
| EditorDisplayMode::Minimap { .. } => {
|
||||
let buffer_font_size = self.style.text.font_size;
|
||||
match buffer_font_size {
|
||||
AbsoluteLength::Pixels(pixels) => {
|
||||
|
@ -7877,7 +7877,7 @@ impl EditorElement {
|
|||
}
|
||||
|
||||
fn editor_with_selections(&self, cx: &App) -> Option<Entity<Editor>> {
|
||||
if let EditorMode::Minimap { parent } = self.editor.read(cx).mode() {
|
||||
if let EditorDisplayMode::Minimap { parent } = self.editor.read(cx).display_mode() {
|
||||
parent.upgrade()
|
||||
} else {
|
||||
Some(self.editor.clone())
|
||||
|
@ -7909,8 +7909,8 @@ impl Element for EditorElement {
|
|||
self.editor.update(cx, |editor, cx| {
|
||||
editor.set_style(self.style.clone(), window, cx);
|
||||
|
||||
let layout_id = match editor.mode {
|
||||
EditorMode::SingleLine => {
|
||||
let layout_id = match editor.display_mode {
|
||||
EditorDisplayMode::SingleLine => {
|
||||
let rem_size = window.rem_size();
|
||||
let height = self.style.text.line_height_in_pixels(rem_size);
|
||||
let mut style = Style::default();
|
||||
|
@ -7918,7 +7918,7 @@ impl Element for EditorElement {
|
|||
style.size.width = relative(1.).into();
|
||||
window.request_layout(style, None, cx)
|
||||
}
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines,
|
||||
max_lines,
|
||||
} => {
|
||||
|
@ -7945,13 +7945,13 @@ impl Element for EditorElement {
|
|||
},
|
||||
)
|
||||
}
|
||||
EditorMode::Minimap { .. } => {
|
||||
EditorDisplayMode::Minimap { .. } => {
|
||||
let mut style = Style::default();
|
||||
style.size.width = relative(1.).into();
|
||||
style.size.height = relative(1.).into();
|
||||
window.request_layout(style, None, cx)
|
||||
}
|
||||
EditorMode::Full {
|
||||
EditorDisplayMode::Full {
|
||||
sized_by_content, ..
|
||||
} => {
|
||||
let mut style = Style::default();
|
||||
|
@ -7990,7 +7990,7 @@ impl Element for EditorElement {
|
|||
..Default::default()
|
||||
};
|
||||
|
||||
let is_minimap = self.editor.read(cx).mode.is_minimap();
|
||||
let is_minimap = self.editor.read(cx).display_mode.is_minimap();
|
||||
|
||||
if !is_minimap {
|
||||
let focus_handle = self.editor.focus_handle(cx);
|
||||
|
@ -8065,8 +8065,9 @@ impl Element for EditorElement {
|
|||
editor.set_visible_column_count(editor_width / em_advance);
|
||||
|
||||
if matches!(
|
||||
editor.mode,
|
||||
EditorMode::AutoHeight { .. } | EditorMode::Minimap { .. }
|
||||
editor.display_mode,
|
||||
EditorDisplayMode::AutoHeight { .. }
|
||||
| EditorDisplayMode::Minimap { .. }
|
||||
) {
|
||||
snapshot
|
||||
} else {
|
||||
|
@ -8112,10 +8113,10 @@ impl Element for EditorElement {
|
|||
|
||||
// The max scroll position for the top of the window
|
||||
let max_scroll_top = if matches!(
|
||||
snapshot.mode,
|
||||
EditorMode::SingleLine
|
||||
| EditorMode::AutoHeight { .. }
|
||||
| EditorMode::Full {
|
||||
snapshot.display_mode,
|
||||
EditorDisplayMode::SingleLine
|
||||
| EditorDisplayMode::AutoHeight { .. }
|
||||
| EditorDisplayMode::Full {
|
||||
sized_by_content: true,
|
||||
..
|
||||
}
|
||||
|
@ -8980,7 +8981,7 @@ impl Element for EditorElement {
|
|||
None,
|
||||
);
|
||||
|
||||
let mode = snapshot.mode.clone();
|
||||
let mode = snapshot.display_mode.clone();
|
||||
|
||||
let (diff_hunk_controls, diff_hunk_control_bounds) = if is_read_only {
|
||||
(vec![], vec![])
|
||||
|
@ -9209,7 +9210,7 @@ pub struct EditorLayout {
|
|||
content_origin: gpui::Point<Pixels>,
|
||||
scrollbars_layout: Option<EditorScrollbars>,
|
||||
minimap: Option<MinimapLayout>,
|
||||
mode: EditorMode,
|
||||
mode: EditorDisplayMode,
|
||||
wrap_guides: SmallVec<[(Pixels, bool); 2]>,
|
||||
indent_guides: Option<Vec<IndentGuideLayout>>,
|
||||
visible_display_row_range: Range<DisplayRow>,
|
||||
|
@ -9788,7 +9789,7 @@ pub fn layout_line(
|
|||
style,
|
||||
MAX_LINE_LEN,
|
||||
1,
|
||||
&snapshot.mode,
|
||||
&snapshot.display_mode,
|
||||
text_width,
|
||||
is_row_soft_wrapped,
|
||||
window,
|
||||
|
@ -10197,7 +10198,7 @@ mod tests {
|
|||
let window = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), cx);
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: None,
|
||||
},
|
||||
|
@ -10233,7 +10234,7 @@ mod tests {
|
|||
|
||||
let window = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), cx);
|
||||
let mut editor = Editor::new(EditorMode::full(), buffer, None, window, cx);
|
||||
let mut editor = Editor::new(EditorDisplayMode::full(), buffer, None, window, cx);
|
||||
editor.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);
|
||||
editor
|
||||
});
|
||||
|
@ -10260,7 +10261,7 @@ mod tests {
|
|||
init_test(cx, |_| {});
|
||||
let window = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
||||
Editor::new(EditorMode::full(), buffer, None, window, cx)
|
||||
Editor::new(EditorDisplayMode::full(), buffer, None, window, cx)
|
||||
});
|
||||
|
||||
let editor = window.root(cx).unwrap();
|
||||
|
@ -10361,7 +10362,7 @@ mod tests {
|
|||
|
||||
let window = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple(&(sample_text(6, 6, 'a') + "\n"), cx);
|
||||
Editor::new(EditorMode::full(), buffer, None, window, cx)
|
||||
Editor::new(EditorDisplayMode::full(), buffer, None, window, cx)
|
||||
});
|
||||
let cx = &mut VisualTestContext::from_window(*window, cx);
|
||||
let editor = window.root(cx).unwrap();
|
||||
|
@ -10432,7 +10433,7 @@ mod tests {
|
|||
|
||||
let window = cx.add_window(|window, cx| {
|
||||
let buffer = MultiBuffer::build_simple("", cx);
|
||||
Editor::new(EditorMode::full(), buffer, None, window, cx)
|
||||
Editor::new(EditorDisplayMode::full(), buffer, None, window, cx)
|
||||
});
|
||||
let cx = &mut VisualTestContext::from_window(*window, cx);
|
||||
let editor = window.root(cx).unwrap();
|
||||
|
@ -10518,7 +10519,7 @@ mod tests {
|
|||
|
||||
let actual_invisibles = collect_invisibles_from_new_editor(
|
||||
cx,
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
input_text,
|
||||
px(500.0),
|
||||
show_line_numbers,
|
||||
|
@ -10536,8 +10537,8 @@ mod tests {
|
|||
});
|
||||
|
||||
for editor_mode_without_invisibles in [
|
||||
EditorMode::SingleLine,
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::SingleLine,
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(100),
|
||||
},
|
||||
|
@ -10615,7 +10616,7 @@ mod tests {
|
|||
|
||||
let actual_invisibles = collect_invisibles_from_new_editor(
|
||||
cx,
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
&input_text,
|
||||
px(editor_width),
|
||||
show_line_numbers,
|
||||
|
@ -10654,7 +10655,7 @@ mod tests {
|
|||
|
||||
fn collect_invisibles_from_new_editor(
|
||||
cx: &mut TestAppContext,
|
||||
editor_mode: EditorMode,
|
||||
editor_mode: EditorDisplayMode,
|
||||
input_text: &str,
|
||||
editor_width: Pixels,
|
||||
show_line_numbers: bool,
|
||||
|
|
|
@ -1267,7 +1267,7 @@ impl SerializableItem for Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<Task<Result<()>>> {
|
||||
if self.mode.is_minimap() {
|
||||
if self.display_mode.is_minimap() {
|
||||
return None;
|
||||
}
|
||||
let mut serialize_dirty_buffers = self.serialize_dirty_buffers;
|
||||
|
@ -1424,7 +1424,7 @@ impl Editor {
|
|||
cx: &mut Context<Self>,
|
||||
write: impl for<'a> FnOnce(&'a mut RestorationData) + 'static,
|
||||
) {
|
||||
if self.mode.is_minimap() || !WorkspaceSettings::get(None, cx).restore_on_file_reopen {
|
||||
if self.display_mode.is_minimap() || !WorkspaceSettings::get(None, cx).restore_on_file_reopen {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ impl Editor {
|
|||
_: &Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if !self.mode().is_full() {
|
||||
if !self.display_mode().is_full() {
|
||||
return;
|
||||
}
|
||||
let Some(project) = self.project.clone() else {
|
||||
|
|
|
@ -153,7 +153,7 @@ pub fn deploy_context_menu(
|
|||
}
|
||||
|
||||
// Don't show context menu for inline editors
|
||||
if !editor.mode().is_full() {
|
||||
if !editor.display_mode().is_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ pub(crate) mod scroll_amount;
|
|||
|
||||
use crate::editor_settings::ScrollBeyondLastLine;
|
||||
use crate::{
|
||||
Anchor, DisplayPoint, DisplayRow, Editor, EditorEvent, EditorMode, EditorSettings,
|
||||
Anchor, DisplayPoint, DisplayRow, Editor, EditorDisplayMode, EditorEvent, EditorSettings,
|
||||
InlayHintRefreshReason, MultiBufferSnapshot, RowExt, ToPoint,
|
||||
display_map::{DisplaySnapshot, ToDisplayPoint},
|
||||
hover_popover::hide_hover,
|
||||
|
@ -675,7 +675,7 @@ impl Editor {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use super::Axis;
|
||||
use crate::{
|
||||
Autoscroll, Editor, EditorMode, NextScreen, NextScrollCursorCenterTopBottom,
|
||||
Autoscroll, Editor, EditorDisplayMode, NextScreen, NextScrollCursorCenterTopBottom,
|
||||
SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT, ScrollCursorBottom, ScrollCursorCenter,
|
||||
ScrollCursorCenterTopBottom, ScrollCursorTop, display_map::DisplayRow,
|
||||
};
|
||||
|
@ -16,7 +16,7 @@ impl Editor {
|
|||
return;
|
||||
}
|
||||
|
||||
if matches!(self.mode, EditorMode::SingleLine) {
|
||||
if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
DisplayRow, Editor, EditorMode, LineWithInvisibles, RowExt, SelectionEffects,
|
||||
DisplayRow, Editor, EditorDisplayMode, LineWithInvisibles, RowExt, SelectionEffects,
|
||||
display_map::ToDisplayPoint, scroll::WasScrolled,
|
||||
};
|
||||
use gpui::{Bounds, Context, Pixels, Window, px};
|
||||
|
@ -184,7 +184,7 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
let margin = if matches!(self.mode, EditorMode::AutoHeight { .. }) {
|
||||
let margin = if matches!(self.display_mode, EditorDisplayMode::AutoHeight { .. }) {
|
||||
0.
|
||||
} else {
|
||||
((visible_lines - (target_bottom - target_top)) / 2.0).floor()
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{rc::Rc, sync::LazyLock};
|
|||
|
||||
pub use crate::rust_analyzer_ext::expand_macro_recursively;
|
||||
use crate::{
|
||||
DisplayPoint, Editor, EditorMode, FoldPlaceholder, MultiBuffer, SelectionEffects,
|
||||
DisplayPoint, Editor, EditorDisplayMode, FoldPlaceholder, MultiBuffer, SelectionEffects,
|
||||
display_map::{
|
||||
Block, BlockPlacement, CustomBlockId, DisplayMap, DisplayRow, DisplaySnapshot,
|
||||
ToDisplayPoint,
|
||||
|
@ -121,7 +121,7 @@ pub(crate) fn build_editor(
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> Editor {
|
||||
Editor::new(EditorMode::full(), buffer, None, window, cx)
|
||||
Editor::new(EditorDisplayMode::full(), buffer, None, window, cx)
|
||||
}
|
||||
|
||||
pub(crate) fn build_editor_with_project(
|
||||
|
@ -130,7 +130,7 @@ pub(crate) fn build_editor_with_project(
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> Editor {
|
||||
Editor::new(EditorMode::full(), buffer, Some(project), window, cx)
|
||||
Editor::new(EditorDisplayMode::full(), buffer, Some(project), window, cx)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -44,7 +44,7 @@ impl editor::Addon for ConflictAddon {
|
|||
|
||||
pub fn register_editor(editor: &mut Editor, buffer: Entity<MultiBuffer>, cx: &mut Context<Editor>) {
|
||||
// Only show conflict UI for singletons and in the project diff.
|
||||
if !editor.mode().is_full()
|
||||
if !editor.display_mode().is_full()
|
||||
|| (!editor.buffer().read(cx).is_singleton()
|
||||
&& !editor.buffer().read(cx).all_diff_hunks_expanded())
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ use anyhow::Context as _;
|
|||
use askpass::AskPassDelegate;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use editor::{
|
||||
Editor, EditorElement, EditorMode, EditorSettings, MultiBuffer, ShowScrollbar,
|
||||
Editor, EditorDisplayMode, EditorElement, EditorSettings, MultiBuffer, ShowScrollbar,
|
||||
scroll::ScrollbarAutoHide,
|
||||
};
|
||||
use futures::StreamExt as _;
|
||||
|
@ -394,7 +394,7 @@ pub(crate) fn commit_message_editor(
|
|||
let buffer = cx.new(|cx| MultiBuffer::singleton(commit_message_buffer, cx));
|
||||
let max_lines = if in_panel { MAX_PANEL_EDITOR_LINES } else { 18 };
|
||||
let mut commit_editor = Editor::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(max_lines),
|
||||
},
|
||||
|
|
|
@ -104,14 +104,14 @@ impl CursorPosition {
|
|||
cursor_position.update(cx, |cursor_position, cx| {
|
||||
cursor_position.selected_count = SelectionStats::default();
|
||||
cursor_position.selected_count.selections = editor.selections.count();
|
||||
match editor.mode() {
|
||||
editor::EditorMode::AutoHeight { .. }
|
||||
| editor::EditorMode::SingleLine
|
||||
| editor::EditorMode::Minimap { .. } => {
|
||||
match editor.display_mode() {
|
||||
editor::EditorDisplayMode::AutoHeight { .. }
|
||||
| editor::EditorDisplayMode::SingleLine
|
||||
| editor::EditorDisplayMode::Minimap { .. } => {
|
||||
cursor_position.position = None;
|
||||
cursor_position.context = None;
|
||||
}
|
||||
editor::EditorMode::Full { .. } => {
|
||||
editor::EditorDisplayMode::Full { .. } => {
|
||||
let mut last_selection = None::<Selection<Point>>;
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
if snapshot.excerpts().count() > 0 {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use anyhow::{Result, anyhow};
|
||||
use editor::{
|
||||
Bias, CompletionProvider, Editor, EditorEvent, EditorMode, ExcerptId, MinimapVisibility,
|
||||
Bias, CompletionProvider, Editor, EditorDisplayMode, EditorEvent, ExcerptId, MinimapVisibility,
|
||||
MultiBuffer,
|
||||
};
|
||||
use fuzzy::StringMatch;
|
||||
|
@ -483,7 +483,7 @@ impl DivInspector {
|
|||
cx.new(|cx| {
|
||||
let multi_buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::full(),
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer,
|
||||
Some(self.project.clone()),
|
||||
window,
|
||||
|
|
|
@ -88,7 +88,7 @@ impl Render for OutlineView {
|
|||
|
||||
impl OutlineView {
|
||||
fn register(editor: &mut Editor, _: Option<&mut Window>, cx: &mut Context<Editor>) {
|
||||
if editor.mode().is_full() {
|
||||
if editor.display_mode().is_full() {
|
||||
let handle = cx.entity().downgrade();
|
||||
editor
|
||||
.register_action(move |action, window, cx| {
|
||||
|
|
|
@ -4949,7 +4949,7 @@ fn workspace_active_editor(
|
|||
let active_item = workspace.active_item(cx)?;
|
||||
let active_editor = active_item
|
||||
.act_as::<Editor>(cx)
|
||||
.filter(|editor| editor.read(cx).mode().is_full())?;
|
||||
.filter(|editor| editor.read(cx).display_mode().is_full())?;
|
||||
Some((active_item, active_editor))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#![allow(unused, dead_code)]
|
||||
use std::sync::Arc;
|
||||
|
||||
use editor::{Editor, EditorMode, MultiBuffer};
|
||||
use editor::{Editor, EditorDisplayMode, MultiBuffer};
|
||||
use futures::future::Shared;
|
||||
use gpui::{
|
||||
App, Entity, Hsla, RetainAllImageCache, Task, TextStyleRefinement, image_cache, prelude::*,
|
||||
|
@ -177,7 +177,7 @@ impl Cell {
|
|||
|
||||
let editor_view = cx.new(|cx| {
|
||||
let mut editor = Editor::new(
|
||||
EditorMode::AutoHeight {
|
||||
EditorDisplayMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: Some(1024),
|
||||
},
|
||||
|
|
|
@ -2699,7 +2699,7 @@ impl ActionArgumentsEditor {
|
|||
let editor = cx.new_window_entity(|window, cx| {
|
||||
let multi_buffer = cx.new(|cx| editor::MultiBuffer::singleton(buffer, cx));
|
||||
let mut editor = Editor::new(
|
||||
editor::EditorMode::Full {
|
||||
editor::EditorDisplayMode::Full {
|
||||
scale_ui_elements_with_buffer_font_size: true,
|
||||
show_active_line_background: false,
|
||||
sized_by_content: true,
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::time::Duration;
|
|||
use collections::HashMap;
|
||||
use command_palette::CommandPalette;
|
||||
use editor::{
|
||||
AnchorRangeExt, DisplayPoint, Editor, EditorMode, MultiBuffer, actions::DeleteLine,
|
||||
AnchorRangeExt, DisplayPoint, Editor, EditorDisplayMode, MultiBuffer, actions::DeleteLine,
|
||||
display_map::DisplayRow, test::editor_test_context::EditorTestContext,
|
||||
};
|
||||
use futures::StreamExt;
|
||||
|
@ -1784,7 +1784,13 @@ async fn test_folded_multibuffer_excerpts(cx: &mut gpui::TestAppContext) {
|
|||
],
|
||||
cx,
|
||||
);
|
||||
let mut editor = Editor::new(EditorMode::full(), multi_buffer.clone(), None, window, cx);
|
||||
let mut editor = Editor::new(
|
||||
EditorDisplayMode::full(),
|
||||
multi_buffer.clone(),
|
||||
None,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
|
||||
let buffer_ids = multi_buffer.read(cx).excerpt_buffer_ids();
|
||||
// fold all but the second buffer, so that we test navigating between two
|
||||
|
|
|
@ -1222,7 +1222,7 @@ impl Vim {
|
|||
editor.selections.newest::<usize>(cx).is_empty()
|
||||
});
|
||||
let editor = editor.read(cx);
|
||||
let editor_mode = editor.mode();
|
||||
let editor_mode = editor.display_mode();
|
||||
|
||||
if editor_mode.is_full()
|
||||
&& !newest_selection_empty
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
|
|||
let client = client.clone();
|
||||
let user_store = user_store.clone();
|
||||
move |editor: &mut Editor, window, cx: &mut Context<Editor>| {
|
||||
if !editor.mode().is_full() {
|
||||
if !editor.display_mode().is_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ impl Render for QuickActionBar {
|
|||
let selection_menu_enabled = editor_value.selection_menu_enabled(cx);
|
||||
let inlay_hints_enabled = editor_value.inlay_hints_enabled();
|
||||
let inline_values_enabled = editor_value.inline_values_enabled();
|
||||
let supports_diagnostics = editor_value.mode().is_full();
|
||||
let supports_diagnostics = editor_value.display_mode().is_full();
|
||||
let diagnostics_enabled = editor_value.diagnostics_max_severity != DiagnosticSeverity::Off;
|
||||
let supports_inline_diagnostics = editor_value.inline_diagnostics_enabled();
|
||||
let inline_diagnostics_enabled = editor_value.show_inline_diagnostics();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue