editor mode -> display mode

Co-authored-by: Oleksiy Syvokon <oleksiy.syvokon@gmail.com>
This commit is contained in:
Smit Barmase 2025-08-22 14:08:21 +05:30
parent 57a0bb327d
commit c6d0d75711
No known key found for this signature in database
33 changed files with 255 additions and 225 deletions

View file

@ -4,7 +4,7 @@ use acp_thread::{AcpThread, AgentThreadEntry};
use agent_client_protocol::{PromptCapabilities, ToolCallId}; use agent_client_protocol::{PromptCapabilities, ToolCallId};
use agent2::HistoryStore; use agent2::HistoryStore;
use collections::HashMap; use collections::HashMap;
use editor::{Editor, EditorMode, MinimapVisibility}; use editor::{Editor, EditorDisplayMode, MinimapVisibility};
use gpui::{ use gpui::{
AnyEntity, App, AppContext as _, Entity, EntityId, EventEmitter, Focusable, AnyEntity, App, AppContext as _, Entity, EntityId, EventEmitter, Focusable,
TextStyleRefinement, WeakEntity, Window, TextStyleRefinement, WeakEntity, Window,
@ -87,7 +87,7 @@ impl EntryViewState {
self.prompt_capabilities.clone(), self.prompt_capabilities.clone(),
"Edit message @ to include context", "Edit message @ to include context",
self.prevent_slash_commands, self.prevent_slash_commands,
editor::EditorMode::AutoHeight { editor::EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: None, max_lines: None,
}, },
@ -287,7 +287,7 @@ fn create_editor_diff(
) -> Entity<Editor> { ) -> Entity<Editor> {
cx.new(|cx| { cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::Full { EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: false, scale_ui_elements_with_buffer_font_size: false,
show_active_line_background: false, show_active_line_background: false,
sized_by_content: true, sized_by_content: true,

View file

@ -10,9 +10,9 @@ use anyhow::{Context as _, Result, anyhow};
use assistant_slash_commands::codeblock_fence_for_path; use assistant_slash_commands::codeblock_fence_for_path;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use editor::{ use editor::{
Addon, Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement, Addon, Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor,
EditorEvent, EditorMode, EditorSnapshot, EditorStyle, ExcerptId, FoldPlaceholder, MultiBuffer, EditorDisplayMode, EditorElement, EditorEvent, EditorSnapshot, EditorStyle, ExcerptId,
SemanticsProvider, ToOffset, FoldPlaceholder, MultiBuffer, SemanticsProvider, ToOffset,
actions::Paste, actions::Paste,
display_map::{Crease, CreaseId, FoldId}, display_map::{Crease, CreaseId, FoldId},
}; };
@ -90,7 +90,7 @@ impl MessageEditor {
prompt_capabilities: Rc<Cell<acp::PromptCapabilities>>, prompt_capabilities: Rc<Cell<acp::PromptCapabilities>>,
placeholder: impl Into<Arc<str>>, placeholder: impl Into<Arc<str>>,
prevent_slash_commands: bool, prevent_slash_commands: bool,
mode: EditorMode, mode: EditorDisplayMode,
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> 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| { self.editor.update(cx, |editor, cx| {
editor.set_mode(mode); editor.set_display_mode(mode);
cx.notify() cx.notify()
}); });
} }
@ -1858,7 +1858,7 @@ mod tests {
use agent_client_protocol as acp; use agent_client_protocol as acp;
use agent2::HistoryStore; use agent2::HistoryStore;
use assistant_context::ContextStore; use assistant_context::ContextStore;
use editor::{AnchorRangeExt as _, Editor, EditorMode}; use editor::{AnchorRangeExt as _, Editor, EditorDisplayMode};
use fs::FakeFs; use fs::FakeFs;
use futures::StreamExt as _; use futures::StreamExt as _;
use gpui::{ use gpui::{
@ -1901,7 +1901,7 @@ mod tests {
Default::default(), Default::default(),
"Test", "Test",
false, false,
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: None, max_lines: None,
}, },
@ -2102,7 +2102,7 @@ mod tests {
prompt_capabilities.clone(), prompt_capabilities.clone(),
"Test", "Test",
false, false,
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
max_lines: None, max_lines: None,
min_lines: 1, min_lines: 1,
}, },

View file

@ -15,7 +15,7 @@ use buffer_diff::BufferDiff;
use client::zed_urls; use client::zed_urls;
use collections::{HashMap, HashSet}; use collections::{HashMap, HashSet};
use editor::scroll::Autoscroll; 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 file_icons::FileIcons;
use fs::Fs; use fs::Fs;
use gpui::{ use gpui::{
@ -228,7 +228,7 @@ impl ThreadFeedbackState {
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
editor::EditorMode::AutoHeight { editor::EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(4), max_lines: Some(4),
}, },
@ -321,7 +321,7 @@ impl AcpThreadView {
prompt_capabilities.clone(), prompt_capabilities.clone(),
"Message the agent — @ to include context", "Message the agent — @ to include context",
prevent_slash_commands, prevent_slash_commands,
editor::EditorMode::AutoHeight { editor::EditorDisplayMode::AutoHeight {
min_lines: MIN_EDITOR_LINES, min_lines: MIN_EDITOR_LINES,
max_lines: Some(MAX_EDITOR_LINES), max_lines: Some(MAX_EDITOR_LINES),
}, },
@ -673,8 +673,8 @@ impl AcpThreadView {
self.editor_expanded = is_expanded; self.editor_expanded = is_expanded;
self.message_editor.update(cx, |editor, cx| { self.message_editor.update(cx, |editor, cx| {
if is_expanded { if is_expanded {
editor.set_mode( editor.set_display_mode(
EditorMode::Full { EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: false, scale_ui_elements_with_buffer_font_size: false,
show_active_line_background: false, show_active_line_background: false,
sized_by_content: false, sized_by_content: false,
@ -682,8 +682,8 @@ impl AcpThreadView {
cx, cx,
) )
} else { } else {
editor.set_mode( editor.set_display_mode(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: MIN_EDITOR_LINES, min_lines: MIN_EDITOR_LINES,
max_lines: Some(MAX_EDITOR_LINES), max_lines: Some(MAX_EDITOR_LINES),
}, },

View file

@ -1723,7 +1723,7 @@ impl ActiveThread {
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
editor::EditorMode::AutoHeight { editor::EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(4), max_lines: Some(4),
}, },

View file

@ -1046,7 +1046,7 @@ impl ToolbarItemView for AgentDiffToolbar {
} }
if let Some(editor) = item.act_as::<Editor>(cx) 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); let agent_diff = AgentDiff::global(cx);
@ -1549,7 +1549,7 @@ impl AgentDiff {
} }
fn full_editor_buffer(editor: &Editor, cx: &App) -> Option<WeakEntity<Buffer>> { fn full_editor_buffer(editor: &Editor, cx: &App) -> Option<WeakEntity<Buffer>> {
if editor.mode().is_full() { if editor.display_mode().is_full() {
editor editor
.buffer() .buffer()
.read(cx) .read(cx)

View file

@ -1244,7 +1244,7 @@ mod tests {
let editor = workspace.update_in(&mut cx, |workspace, window, cx| { let editor = workspace.update_in(&mut cx, |workspace, window, cx| {
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
Editor::new( Editor::new(
editor::EditorMode::full(), editor::EditorDisplayMode::full(),
multi_buffer::MultiBuffer::build_simple("", cx), multi_buffer::MultiBuffer::build_simple("", cx),
None, None,
window, window,

View file

@ -16,7 +16,8 @@ use db::kvp::Dismissable;
use editor::actions::Paste; use editor::actions::Paste;
use editor::display_map::EditorMargins; use editor::display_map::EditorMargins;
use editor::{ use editor::{
ContextMenuOptions, Editor, EditorElement, EditorEvent, EditorMode, EditorStyle, MultiBuffer, ContextMenuOptions, Editor, EditorDisplayMode, EditorElement, EditorEvent, EditorStyle,
MultiBuffer,
actions::{MoveDown, MoveUp}, actions::{MoveDown, MoveUp},
}; };
use feature_flags::{FeatureFlagAppExt as _, ZedProFeatureFlag}; use feature_flags::{FeatureFlagAppExt as _, ZedProFeatureFlag};
@ -869,7 +870,7 @@ impl PromptEditor<BufferCodegen> {
let prompt_editor = cx.new(|cx| { let prompt_editor = cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(Self::MAX_LINES as usize), max_lines: Some(Self::MAX_LINES as usize),
}, },
@ -1048,7 +1049,7 @@ impl PromptEditor<TerminalCodegen> {
let prompt_editor = cx.new(|cx| { let prompt_editor = cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(Self::MAX_LINES as usize), max_lines: Some(Self::MAX_LINES as usize),
}, },

View file

@ -22,8 +22,8 @@ use collections::{HashMap, HashSet};
use editor::actions::{MoveUp, Paste}; use editor::actions::{MoveUp, Paste};
use editor::display_map::CreaseId; use editor::display_map::CreaseId;
use editor::{ use editor::{
Addon, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement, Addon, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorDisplayMode,
EditorEvent, EditorMode, EditorStyle, MultiBuffer, EditorElement, EditorEvent, EditorStyle, MultiBuffer,
}; };
use file_icons::FileIcons; use file_icons::FileIcons;
use fs::Fs; use fs::Fs;
@ -127,7 +127,7 @@ pub(crate) fn create_editor(
}; };
let mut editor = Editor::new( let mut editor = Editor::new(
editor::EditorMode::AutoHeight { editor::EditorDisplayMode::AutoHeight {
min_lines, min_lines,
max_lines, max_lines,
}, },
@ -312,13 +312,13 @@ impl MessageEditor {
self.editor_is_expanded = is_expanded; self.editor_is_expanded = is_expanded;
self.editor.update(cx, |editor, _| { self.editor.update(cx, |editor, _| {
if self.editor_is_expanded { if self.editor_is_expanded {
editor.set_mode(EditorMode::Full { editor.set_display_mode(EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: false, scale_ui_elements_with_buffer_font_size: false,
show_active_line_background: false, show_active_line_background: false,
sized_by_content: false, sized_by_content: false,
}) })
} else { } else {
editor.set_mode(EditorMode::AutoHeight { editor.set_display_mode(EditorDisplayMode::AutoHeight {
min_lines: MIN_EDITOR_LINES, min_lines: MIN_EDITOR_LINES,
max_lines: Some(MAX_EDITOR_LINES), max_lines: Some(MAX_EDITOR_LINES),
}) })

View file

@ -11,7 +11,7 @@ use assistant_tool::{
AnyToolCard, Tool, ToolCard, ToolResult, ToolResultContent, ToolResultOutput, ToolUseStatus, AnyToolCard, Tool, ToolCard, ToolResult, ToolResultContent, ToolResultOutput, ToolUseStatus,
}; };
use buffer_diff::{BufferDiff, BufferDiffSnapshot}; use buffer_diff::{BufferDiff, BufferDiffSnapshot};
use editor::{Editor, EditorMode, MinimapVisibility, MultiBuffer, PathKey}; use editor::{Editor, EditorDisplayMode, MinimapVisibility, MultiBuffer, PathKey};
use futures::StreamExt; use futures::StreamExt;
use gpui::{ use gpui::{
Animation, AnimationExt, AnyWindowHandle, App, AppContext, AsyncApp, Entity, Task, Animation, AnimationExt, AnyWindowHandle, App, AppContext, AsyncApp, Entity, Task,
@ -582,7 +582,7 @@ impl EditFileToolCard {
let editor = cx.new(|cx| { let editor = cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::Full { EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: false, scale_ui_elements_with_buffer_font_size: false,
show_active_line_background: false, show_active_line_background: false,
sized_by_content: true, sized_by_content: true,

View file

@ -14,7 +14,7 @@ use dap::{
}, },
}; };
use editor::{ use editor::{
ActiveDebugLine, Editor, EditorMode, MultiBuffer, ActiveDebugLine, Editor, EditorDisplayMode, MultiBuffer,
actions::{self}, actions::{self},
}; };
use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext}; 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| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project.clone()), Some(project.clone()),
window, window,
@ -1290,7 +1290,7 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
let (first_editor, cx) = cx.add_window_view(|window, cx| { let (first_editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(first, cx), MultiBuffer::build_from_buffer(first, cx),
Some(project.clone()), Some(project.clone()),
window, window,
@ -1300,7 +1300,7 @@ async fn test_unsetting_breakpoints_on_clear_breakpoint_action(
let (second_editor, cx) = cx.add_window_view(|window, cx| { let (second_editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(second, cx), MultiBuffer::build_from_buffer(second, cx),
Some(project.clone()), Some(project.clone()),
window, 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| { let (main_editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(main_buffer, cx), MultiBuffer::build_from_buffer(main_buffer, cx),
Some(project.clone()), Some(project.clone()),
window, 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| { let (second_editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(second_buffer, cx), MultiBuffer::build_from_buffer(second_buffer, cx),
Some(project.clone()), Some(project.clone()),
window, window,

View file

@ -1,7 +1,7 @@
use std::{path::Path, sync::Arc}; use std::{path::Path, sync::Arc};
use dap::{Scope, StackFrame, Variable, requests::Variables}; use dap::{Scope, StackFrame, Variable, requests::Variables};
use editor::{Editor, EditorMode, MultiBuffer}; use editor::{Editor, EditorDisplayMode, MultiBuffer};
use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext}; use gpui::{BackgroundExecutor, TestAppContext, VisualTestContext};
use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_python, tree_sitter_rust}; use language::{Language, LanguageConfig, LanguageMatcher, tree_sitter_python, tree_sitter_rust};
use project::{FakeFs, Project}; use project::{FakeFs, Project};
@ -226,7 +226,7 @@ fn main() {
let (editor, cx) = cx.add_window_view(|window, cx| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project), Some(project),
window, 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| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project), Some(project),
window, window,
@ -2093,7 +2093,7 @@ async fn test_inline_values_util(
let (editor, cx) = cx.add_window_view(|window, cx| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project), Some(project),
window, window,

View file

@ -496,7 +496,7 @@ pub enum SelectMode {
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub enum EditorMode { pub enum EditorDisplayMode {
SingleLine, SingleLine,
AutoHeight { AutoHeight {
min_lines: usize, min_lines: usize,
@ -515,7 +515,7 @@ pub enum EditorMode {
}, },
} }
impl EditorMode { impl EditorDisplayMode {
pub fn full() -> Self { pub fn full() -> Self {
Self::Full { Self::Full {
scale_ui_elements_with_buffer_font_size: true, scale_ui_elements_with_buffer_font_size: true,
@ -759,7 +759,7 @@ pub enum MinimapVisibility {
} }
impl MinimapVisibility { impl MinimapVisibility {
fn for_mode(mode: &EditorMode, cx: &App) -> Self { fn for_display_mode(mode: &EditorDisplayMode, cx: &App) -> Self {
if mode.is_full() { if mode.is_full() {
Self::Enabled { Self::Enabled {
setting_configuration: EditorSettings::get_global(cx).minimap.minimap_enabled(), setting_configuration: EditorSettings::get_global(cx).minimap.minimap_enabled(),
@ -1046,7 +1046,7 @@ pub struct Editor {
show_cursor_names: bool, show_cursor_names: bool,
hovered_cursors: HashMap<HoveredCursor, Task<()>>, hovered_cursors: HashMap<HoveredCursor, Task<()>>,
pub show_local_selections: bool, pub show_local_selections: bool,
mode: EditorMode, display_mode: EditorDisplayMode,
show_breadcrumbs: bool, show_breadcrumbs: bool,
show_gutter: bool, show_gutter: bool,
show_scrollbars: ScrollbarAxes, show_scrollbars: ScrollbarAxes,
@ -1236,7 +1236,7 @@ impl NextScrollCursorCenterTopBottom {
#[derive(Clone)] #[derive(Clone)]
pub struct EditorSnapshot { pub struct EditorSnapshot {
pub mode: EditorMode, pub display_mode: EditorDisplayMode,
show_gutter: bool, show_gutter: bool,
show_line_numbers: Option<bool>, show_line_numbers: Option<bool>,
show_git_diff_gutter: 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 { 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| Buffer::local("", cx));
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, 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 { 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| Buffer::local("", cx));
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, 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( pub fn auto_height(
@ -1722,7 +1722,7 @@ impl Editor {
let buffer = cx.new(|cx| Buffer::local("", cx)); let buffer = cx.new(|cx| Buffer::local("", cx));
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
Self::new( Self::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines, min_lines,
max_lines: Some(max_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| Buffer::local("", cx));
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
Self::new( Self::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines, min_lines,
max_lines: None, max_lines: None,
}, },
@ -1761,7 +1761,7 @@ impl Editor {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Self { ) -> Self {
let buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); 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( pub fn for_multibuffer(
@ -1770,12 +1770,12 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> 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 { pub fn clone(&self, window: &mut Window, cx: &mut Context<Self>) -> Self {
let mut clone = Self::new( let mut clone = Self::new(
self.mode.clone(), self.display_mode.clone(),
self.buffer.clone(), self.buffer.clone(),
self.project.clone(), self.project.clone(),
window, window,
@ -1796,7 +1796,7 @@ impl Editor {
} }
pub fn new( pub fn new(
mode: EditorMode, mode: EditorDisplayMode,
buffer: Entity<MultiBuffer>, buffer: Entity<MultiBuffer>,
project: Option<Entity<Project>>, project: Option<Entity<Project>>,
window: &mut Window, window: &mut Window,
@ -1806,7 +1806,7 @@ impl Editor {
} }
fn new_internal( fn new_internal(
mode: EditorMode, mode: EditorDisplayMode,
buffer: Entity<MultiBuffer>, buffer: Entity<MultiBuffer>,
project: Option<Entity<Project>>, project: Option<Entity<Project>>,
display_map: Option<Entity<DisplayMap>>, display_map: Option<Entity<DisplayMap>>,
@ -1888,8 +1888,8 @@ impl Editor {
blink_manager blink_manager
}); });
let soft_wrap_mode_override = let soft_wrap_mode_override = matches!(mode, EditorDisplayMode::SingleLine)
matches!(mode, EditorMode::SingleLine).then(|| language_settings::SoftWrap::None); .then(|| language_settings::SoftWrap::None);
let mut project_subscriptions = Vec::new(); let mut project_subscriptions = Vec::new();
if full_mode && let Some(project) = project.as_ref() { if full_mode && let Some(project) = project.as_ref() {
@ -2068,15 +2068,19 @@ impl Editor {
.detach(); .detach();
} }
let show_indent_guides = let show_indent_guides = if matches!(
if matches!(mode, EditorMode::SingleLine | EditorMode::Minimap { .. }) { mode,
Some(false) EditorDisplayMode::SingleLine | EditorDisplayMode::Minimap { .. }
} else { ) {
None Some(false)
}; } else {
None
};
let breakpoint_store = match (&mode, project.as_ref()) { 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, _ => None,
}; };
@ -2132,8 +2136,8 @@ impl Editor {
horizontal: full_mode, horizontal: full_mode,
vertical: full_mode, vertical: full_mode,
}, },
minimap_visibility: MinimapVisibility::for_mode(&mode, cx), minimap_visibility: MinimapVisibility::for_display_mode(&mode, cx),
offset_content: !matches!(mode, EditorMode::SingleLine), offset_content: !matches!(mode, EditorDisplayMode::SingleLine),
show_breadcrumbs: EditorSettings::get_global(cx).toolbar.breadcrumbs, show_breadcrumbs: EditorSettings::get_global(cx).toolbar.breadcrumbs,
show_gutter: full_mode, show_gutter: full_mode,
show_line_numbers: (!full_mode).then_some(false), show_line_numbers: (!full_mode).then_some(false),
@ -2289,7 +2293,7 @@ impl Editor {
.hide_mouse .hide_mouse
.unwrap_or_default(), .unwrap_or_default(),
change_list: ChangeList::new(), change_list: ChangeList::new(),
mode, display_mode: mode,
selection_drag_state: SelectionDragState::None, selection_drag_state: SelectionDragState::None,
folding_newlines: Task::ready(()), folding_newlines: Task::ready(()),
default_editor_mode: vim_mode_setting::EditorMode::default(), default_editor_mode: vim_mode_setting::EditorMode::default(),
@ -2418,7 +2422,7 @@ impl Editor {
editor.update_lsp_data(false, None, window, cx); 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); editor.report_editor_event(ReportEditorEvent::EditorOpened, None, cx);
} }
@ -2487,11 +2491,11 @@ impl Editor {
) -> KeyContext { ) -> KeyContext {
let mut key_context = KeyContext::new_with_defaults(); let mut key_context = KeyContext::new_with_defaults();
key_context.add("Editor"); key_context.add("Editor");
let mode = match self.mode { let mode = match self.display_mode {
EditorMode::SingleLine => "single_line", EditorDisplayMode::SingleLine => "single_line",
EditorMode::AutoHeight { .. } => "auto_height", EditorDisplayMode::AutoHeight { .. } => "auto_height",
EditorMode::Minimap { .. } => "minimap", EditorDisplayMode::Minimap { .. } => "minimap",
EditorMode::Full { .. } => "full", EditorDisplayMode::Full { .. } => "full",
}; };
if EditorSettings::jupyter_enabled(cx) { if EditorSettings::jupyter_enabled(cx) {
@ -2755,7 +2759,7 @@ impl Editor {
.flatten(); .flatten();
EditorSnapshot { EditorSnapshot {
mode: self.mode.clone(), display_mode: self.display_mode.clone(),
show_gutter: self.show_gutter, show_gutter: self.show_gutter,
show_line_numbers: self.show_line_numbers, show_line_numbers: self.show_line_numbers,
show_git_diff_gutter: self.show_git_diff_gutter, show_git_diff_gutter: self.show_git_diff_gutter,
@ -2792,12 +2796,12 @@ impl Editor {
.excerpt_containing(self.selections.newest_anchor().head(), cx) .excerpt_containing(self.selections.newest_anchor().head(), cx)
} }
pub fn mode(&self) -> &EditorMode { pub fn display_mode(&self) -> &EditorDisplayMode {
&self.mode &self.display_mode
} }
pub fn set_mode(&mut self, mode: EditorMode) { pub fn set_display_mode(&mut self, mode: EditorDisplayMode) {
self.mode = mode; self.display_mode = mode;
} }
pub fn collaboration_hub(&self) -> Option<&dyn CollaborationHub> { pub fn collaboration_hub(&self) -> Option<&dyn CollaborationHub> {
@ -3237,7 +3241,7 @@ impl Editor {
use text::ToOffset as _; use text::ToOffset as _;
use text::ToPoint 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 || WorkspaceSettings::get(None, cx).restore_on_startup == RestoreOnStartupBehavior::None
{ {
return; return;
@ -3920,7 +3924,7 @@ impl Editor {
return; return;
} }
if self.mode.is_full() if self.display_mode.is_full()
&& self.change_selections(Default::default(), window, cx, |s| s.try_cancel()) && self.change_selections(Default::default(), window, cx, |s| s.try_cancel())
{ {
return; return;
@ -3963,7 +3967,9 @@ impl Editor {
return true; 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); self.dismiss_diagnostics(cx);
return true; return true;
} }
@ -5177,7 +5183,7 @@ impl Editor {
} }
fn refresh_inlay_hints(&mut self, reason: InlayHintRefreshReason, cx: &mut Context<Self>) { 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; return;
} }
@ -6854,7 +6860,7 @@ impl Editor {
&mut self, &mut self,
cx: &mut Context<Editor>, cx: &mut Context<Editor>,
) -> Option<(String, Range<Anchor>)> { ) -> Option<(String, Range<Anchor>)> {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
return None; return None;
} }
if !EditorSettings::get_global(cx).selection_highlight { 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>) { fn refresh_single_line_folds(&mut self, window: &mut Window, cx: &mut Context<Editor>) {
struct NewlineFold; struct NewlineFold;
let type_id = std::any::TypeId::of::<NewlineFold>(); let type_id = std::any::TypeId::of::<NewlineFold>();
if !self.mode.is_single_line() { if !self.display_mode.is_single_line() {
return; return;
} }
let snapshot = self.snapshot(window, cx); let snapshot = self.snapshot(window, cx);
@ -7179,7 +7185,7 @@ impl Editor {
buffer_position: language::Anchor, buffer_position: language::Anchor,
cx: &App, cx: &App,
) -> EditPredictionSettings { ) -> EditPredictionSettings {
if !self.mode.is_full() if !self.display_mode.is_full()
|| !self.show_edit_predictions_override.unwrap_or(true) || !self.show_edit_predictions_override.unwrap_or(true)
|| self.edit_predictions_disabled_in_scope(buffer, buffer_position, cx) || self.edit_predictions_disabled_in_scope(buffer, buffer_position, cx)
{ {
@ -8518,7 +8524,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut App, cx: &mut App,
) -> Option<(AnyElement, gpui::Point<Pixels>)> { ) -> Option<(AnyElement, gpui::Point<Pixels>)> {
if self.mode().is_minimap() { if self.display_mode().is_minimap() {
return None; return None;
} }
let active_edit_prediction = self.active_edit_prediction.as_ref()?; 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>) { 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(); cx.propagate();
return; return;
} }
@ -9968,7 +9974,7 @@ impl Editor {
} }
pub fn tab(&mut self, _: &Tab, window: &mut Window, cx: &mut Context<Self>) { 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(); cx.propagate();
return; return;
} }
@ -10091,7 +10097,7 @@ impl Editor {
if self.read_only(cx) { if self.read_only(cx) {
return; return;
} }
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -10199,7 +10205,7 @@ impl Editor {
if self.read_only(cx) { if self.read_only(cx) {
return; return;
} }
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -10276,7 +10282,7 @@ impl Editor {
if self.read_only(cx) { if self.read_only(cx) {
return; return;
} }
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -11521,7 +11527,7 @@ impl Editor {
pub fn move_line_up(&mut self, _: &MoveLineUp, window: &mut Window, cx: &mut Context<Self>) { pub fn move_line_up(&mut self, _: &MoveLineUp, window: &mut Window, cx: &mut Context<Self>) {
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx); self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -11632,7 +11638,7 @@ impl Editor {
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx); self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -11784,7 +11790,7 @@ impl Editor {
pub fn rewrap(&mut self, _: &Rewrap, _: &mut Window, cx: &mut Context<Self>) { pub fn rewrap(&mut self, _: &Rewrap, _: &mut Window, cx: &mut Context<Self>) {
self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx); self.hide_mouse_cursor(HideMouseCursorOrigin::TypingAction, cx);
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -12495,7 +12501,7 @@ impl Editor {
return; return;
} }
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -12538,7 +12544,7 @@ impl Editor {
return; return;
} }
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -12575,7 +12581,7 @@ impl Editor {
return; return;
} }
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -12673,7 +12679,7 @@ impl Editor {
return; return;
} }
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -12723,7 +12729,7 @@ impl Editor {
pub fn move_down(&mut self, _: &MoveDown, window: &mut Window, cx: &mut Context<Self>) { pub fn move_down(&mut self, _: &MoveDown, window: &mut Window, cx: &mut Context<Self>) {
self.take_rename(true, window, cx); self.take_rename(true, window, cx);
if self.mode.is_single_line() { if self.display_mode.is_single_line() {
cx.propagate(); cx.propagate();
return; return;
} }
@ -12797,7 +12803,7 @@ impl Editor {
return; return;
} }
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13281,7 +13287,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13302,7 +13308,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13323,7 +13329,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13344,7 +13350,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13365,7 +13371,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13390,7 +13396,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13415,7 +13421,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13440,7 +13446,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13465,7 +13471,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13486,7 +13492,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13507,7 +13513,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13528,7 +13534,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13549,7 +13555,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }
@ -13574,7 +13580,7 @@ impl Editor {
} }
pub fn move_to_end(&mut self, _: &MoveToEnd, window: &mut Window, cx: &mut Context<Self>) { 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(); cx.propagate();
return; return;
} }
@ -14623,7 +14629,7 @@ impl Editor {
let advance_downwards = action.advance_downwards let advance_downwards = action.advance_downwards
&& selections_on_single_row && selections_on_single_row
&& !selections_selecting && !selections_selecting
&& !matches!(this.mode, EditorMode::SingleLine); && !matches!(this.display_mode, EditorDisplayMode::SingleLine);
if advance_downwards { if advance_downwards {
let snapshot = this.buffer.read(cx).snapshot(cx); let snapshot = this.buffer.read(cx).snapshot(cx);
@ -16948,7 +16954,7 @@ impl Editor {
} }
pub fn diagnostics_enabled(&self) -> bool { 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 { pub fn inline_diagnostics_enabled(&self) -> bool {
@ -17108,7 +17114,7 @@ impl Editor {
window: &Window, window: &Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Option<()> { ) -> Option<()> {
if !self.mode().is_full() { if !self.display_mode().is_full() {
return None; return None;
} }
let pull_diagnostics_settings = ProjectSettings::get_global(cx) let pull_diagnostics_settings = ProjectSettings::get_global(cx)
@ -18390,7 +18396,7 @@ impl Editor {
const MINIMAP_FONT_WEIGHT: gpui::FontWeight = gpui::FontWeight::BLACK; const MINIMAP_FONT_WEIGHT: gpui::FontWeight = gpui::FontWeight::BLACK;
let mut minimap = Editor::new_internal( let mut minimap = Editor::new_internal(
EditorMode::Minimap { EditorDisplayMode::Minimap {
parent: cx.weak_entity(), parent: cx.weak_entity(),
}, },
self.buffer.clone(), self.buffer.clone(),
@ -18492,7 +18498,7 @@ impl Editor {
// We intentionally do not inform the display map about the minimap style // We intentionally do not inform the display map about the minimap style
// so that wrapping is not recalculated and stays consistent for the editor // so that wrapping is not recalculated and stays consistent for the editor
// and its linked minimap. // and its linked minimap.
if !self.mode.is_minimap() { if !self.display_mode.is_minimap() {
let rem_size = window.rem_size(); let rem_size = window.rem_size();
self.display_map.update(cx, |map, cx| { self.display_map.update(cx, |map, cx| {
map.set_font( map.set_font(
@ -19038,7 +19044,9 @@ impl Editor {
} }
pub fn render_git_blame_gutter(&self, cx: &App) -> bool { 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 { 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); let project_settings = ProjectSettings::get_global(cx);
self.serialize_dirty_buffers = 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 show_inline_diagnostics = project_settings.diagnostics.inline.enabled;
let inline_blame_enabled = project_settings.git.inline_blame_enabled(); let inline_blame_enabled = project_settings.git.inline_blame_enabled();
if self.show_inline_diagnostics != show_inline_diagnostics { if self.show_inline_diagnostics != show_inline_diagnostics {
@ -20329,7 +20337,7 @@ impl Editor {
!= minimap_settings.minimap_enabled() != minimap_settings.minimap_enabled()
{ {
self.set_minimap_visibility( self.set_minimap_visibility(
MinimapVisibility::for_mode(self.mode(), cx), MinimapVisibility::for_display_mode(self.display_mode(), cx),
window, window,
cx, cx,
); );
@ -21162,7 +21170,7 @@ impl Editor {
} }
pub fn register_addon<T: Addon>(&mut self, instance: T) { pub fn register_addon<T: Addon>(&mut self, instance: T) {
if self.mode.is_minimap() { if self.display_mode.is_minimap() {
return; return;
} }
self.addons self.addons
@ -21215,7 +21223,7 @@ impl Editor {
cx: &mut Context<Editor>, cx: &mut Context<Editor>,
) { ) {
if self.is_singleton(cx) if self.is_singleton(cx)
&& !self.mode.is_minimap() && !self.display_mode.is_minimap()
&& WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None && WorkspaceSettings::get(None, cx).restore_on_startup != RestoreOnStartupBehavior::None
{ {
let buffer_snapshot = OnceCell::new(); 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 { fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let settings = ThemeSettings::get_global(cx); let settings = ThemeSettings::get_global(cx);
let mut text_style = match self.mode { let mut text_style = match self.display_mode {
EditorMode::SingleLine | EditorMode::AutoHeight { .. } => TextStyle { EditorDisplayMode::SingleLine | EditorDisplayMode::AutoHeight { .. } => TextStyle {
color: cx.theme().colors().editor_foreground, color: cx.theme().colors().editor_foreground,
font_family: settings.ui_font.family.clone(), font_family: settings.ui_font.family.clone(),
font_features: settings.ui_font.features.clone(), font_features: settings.ui_font.features.clone(),
@ -22957,7 +22965,7 @@ impl Render for Editor {
line_height: relative(settings.buffer_line_height.value()), line_height: relative(settings.buffer_line_height.value()),
..Default::default() ..Default::default()
}, },
EditorMode::Full { .. } | EditorMode::Minimap { .. } => TextStyle { EditorDisplayMode::Full { .. } | EditorDisplayMode::Minimap { .. } => TextStyle {
color: cx.theme().colors().editor_foreground, color: cx.theme().colors().editor_foreground,
font_family: settings.buffer_font.family.clone(), font_family: settings.buffer_font.family.clone(),
font_features: settings.buffer_font.features.clone(), font_features: settings.buffer_font.features.clone(),
@ -22972,11 +22980,11 @@ impl Render for Editor {
text_style.refine(text_style_refinement) text_style.refine(text_style_refinement)
} }
let background = match self.mode { let background = match self.display_mode {
EditorMode::SingleLine => cx.theme().system().transparent, EditorDisplayMode::SingleLine => cx.theme().system().transparent,
EditorMode::AutoHeight { .. } => cx.theme().system().transparent, EditorDisplayMode::AutoHeight { .. } => cx.theme().system().transparent,
EditorMode::Full { .. } => cx.theme().colors().editor_background, EditorDisplayMode::Full { .. } => cx.theme().colors().editor_background,
EditorMode::Minimap { .. } => cx.theme().colors().editor_background.opacity(0.7), EditorDisplayMode::Minimap { .. } => cx.theme().colors().editor_background.opacity(0.7),
}; };
EditorElement::new( EditorElement::new(
@ -23661,7 +23669,7 @@ impl BreakpointPromptEditor {
let prompt = cx.new(|cx| { let prompt = cx.new(|cx| {
let mut prompt = Editor::new( let mut prompt = Editor::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(Self::MAX_LINES as usize), max_lines: Some(Self::MAX_LINES as usize),
}, },

View file

@ -10075,7 +10075,7 @@ async fn test_multibuffer_format_during_save(cx: &mut TestAppContext) {
}); });
let multi_buffer_editor = cx.new_window_entity(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(project.clone()), Some(project.clone()),
window, window,
@ -10252,7 +10252,7 @@ async fn test_autosave_with_dirty_buffers(cx: &mut TestAppContext) {
let editor = cx.new_window_entity(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(project.clone()), Some(project.clone()),
window, window,
@ -12646,7 +12646,7 @@ async fn test_completion_in_multibuffer_with_replace_range(cx: &mut TestAppConte
.update(cx, |_, window, cx| { .update(cx, |_, window, cx| {
cx.new(|cx| { cx.new(|cx| {
Editor::new( Editor::new(
EditorMode::Full { EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: false, scale_ui_elements_with_buffer_font_size: false,
show_active_line_background: false, show_active_line_background: false,
sized_by_content: 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 cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
let multi_buffer_editor = cx.new_window_entity(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(project.clone()), Some(project.clone()),
window, window,
@ -17900,8 +17900,9 @@ async fn test_toggle_diff_expand_in_multi_buffer(cx: &mut TestAppContext) {
multibuffer multibuffer
}); });
let editor = let editor = cx.add_window(|window, cx| {
cx.add_window(|window, cx| Editor::new(EditorMode::full(), multi_buffer, None, window, cx)); Editor::new(EditorDisplayMode::full(), multi_buffer, None, window, cx)
});
editor editor
.update(cx, |editor, _window, cx| { .update(cx, |editor, _window, cx| {
for (buffer, diff_base) in [ for (buffer, diff_base) in [
@ -18011,8 +18012,9 @@ async fn test_expand_diff_hunk_at_excerpt_boundary(cx: &mut TestAppContext) {
multibuffer multibuffer
}); });
let editor = let editor = cx.add_window(|window, cx| {
cx.add_window(|window, cx| Editor::new(EditorMode::full(), multi_buffer, None, window, cx)); Editor::new(EditorDisplayMode::full(), multi_buffer, None, window, cx)
});
editor editor
.update(cx, |editor, _window, cx| { .update(cx, |editor, _window, cx| {
let diff = cx.new(|cx| BufferDiff::new_with_base_text(base, &buffer, 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| { 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(); 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| { let editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(project.clone()), Some(project.clone()),
window, window,
@ -20332,7 +20340,7 @@ async fn test_folding_buffers(cx: &mut TestAppContext) {
}); });
let multi_buffer_editor = cx.new_window_entity(|window, cx| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer.clone(), multi_buffer.clone(),
Some(project.clone()), Some(project.clone()),
window, 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| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(project.clone()), Some(project.clone()),
window, 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| { let multi_buffer_editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(project.clone()), Some(project.clone()),
window, window,
@ -20659,7 +20667,13 @@ async fn test_multi_buffer_navigation_with_folded_buffers(cx: &mut TestAppContex
], ],
cx, 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(); let buffer_ids = multi_buffer.read(cx).excerpt_buffer_ids();
// fold all but the second buffer, so that we test navigating between two // 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 window = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple(text, 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); 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| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project.clone()), Some(project.clone()),
window, window,
@ -21245,7 +21259,7 @@ async fn test_log_breakpoint_editing(cx: &mut TestAppContext) {
let (editor, cx) = cx.add_window_view(|window, cx| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project.clone()), Some(project.clone()),
window, window,
@ -21415,7 +21429,7 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
let (editor, cx) = cx.add_window_view(|window, cx| { let (editor, cx) = cx.add_window_view(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
MultiBuffer::build_from_buffer(buffer, cx), MultiBuffer::build_from_buffer(buffer, cx),
Some(project.clone()), Some(project.clone()),
window, 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 cx = &mut VisualTestContext::from_window(*workspace.deref(), cx);
let editor = cx.new_window_entity(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
Editor::new( Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
buffer, buffer,
Some(project.clone()), Some(project.clone()),
window, window,

View file

@ -3,7 +3,7 @@ use crate::{
CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter, CodeActionSource, ColumnarMode, ConflictsOurs, ConflictsOursMarker, ConflictsOuter,
ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId, ConflictsTheirs, ConflictsTheirsMarker, ContextMenuPlacement, CursorShape, CustomBlockId,
DisplayDiffHunk, DisplayPoint, DisplayRow, DocumentHighlightRead, DocumentHighlightWrite, 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, EditorStyle, FILE_HEADER_HEIGHT, FocusedBlock, GutterDimensions, HalfPageDown, HalfPageUp,
HandleInput, HoveredCursor, InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp, HandleInput, HoveredCursor, InlayHintRefreshReason, JumpData, LineDown, LineHighlight, LineUp,
MAX_LINE_LEN, MINIMAP_FONT_SIZE, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT, OpenExcerpts, PageDown, 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() || minimap_width.is_zero()
|| matches!( || matches!(
minimap_settings.show, minimap_settings.show,
@ -3212,7 +3212,7 @@ impl EditorElement {
cx: &mut App, cx: &mut App,
) -> Vec<Option<AnyElement>> { ) -> Vec<Option<AnyElement>> {
let include_fold_statuses = EditorSettings::get_global(cx).gutter.folds 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); && self.editor.read(cx).is_singleton(cx);
if include_fold_statuses { if include_fold_statuses {
row_infos row_infos
@ -3314,7 +3314,7 @@ impl EditorElement {
style, style,
MAX_LINE_LEN, MAX_LINE_LEN,
rows.len(), rows.len(),
&snapshot.mode, &snapshot.display_mode,
editor_width, editor_width,
is_row_soft_wrapped, is_row_soft_wrapped,
window, window,
@ -5282,14 +5282,14 @@ impl EditorElement {
if matches!( if matches!(
layout.mode, layout.mode,
EditorMode::Full { .. } | EditorMode::Minimap { .. } EditorDisplayMode::Full { .. } | EditorDisplayMode::Minimap { .. }
) { ) {
let show_active_line_background = match layout.mode { let show_active_line_background = match layout.mode {
EditorMode::Full { EditorDisplayMode::Full {
show_active_line_background, show_active_line_background,
.. ..
} => show_active_line_background, } => show_active_line_background,
EditorMode::Minimap { .. } => true, EditorDisplayMode::Minimap { .. } => true,
_ => false, _ => false,
}; };
let mut active_rows = layout.active_rows.iter().peekable(); let mut active_rows = layout.active_rows.iter().peekable();
@ -7311,7 +7311,7 @@ impl LineWithInvisibles {
editor_style: &EditorStyle, editor_style: &EditorStyle,
max_line_len: usize, max_line_len: usize,
max_line_count: usize, max_line_count: usize,
editor_mode: &EditorMode, editor_mode: &EditorDisplayMode,
text_width: Pixels, text_width: Pixels,
is_row_soft_wrapped: impl Copy + Fn(usize) -> bool, is_row_soft_wrapped: impl Copy + Fn(usize) -> bool,
window: &mut Window, window: &mut Window,
@ -7839,12 +7839,12 @@ impl EditorElement {
/// ///
/// This allows UI elements to scale based on the `buffer_font_size`. /// This allows UI elements to scale based on the `buffer_font_size`.
fn rem_size(&self, cx: &mut App) -> Option<Pixels> { fn rem_size(&self, cx: &mut App) -> Option<Pixels> {
match self.editor.read(cx).mode { match self.editor.read(cx).display_mode {
EditorMode::Full { EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: true, scale_ui_elements_with_buffer_font_size: true,
.. ..
} }
| EditorMode::Minimap { .. } => { | EditorDisplayMode::Minimap { .. } => {
let buffer_font_size = self.style.text.font_size; let buffer_font_size = self.style.text.font_size;
match buffer_font_size { match buffer_font_size {
AbsoluteLength::Pixels(pixels) => { AbsoluteLength::Pixels(pixels) => {
@ -7877,7 +7877,7 @@ impl EditorElement {
} }
fn editor_with_selections(&self, cx: &App) -> Option<Entity<Editor>> { 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() parent.upgrade()
} else { } else {
Some(self.editor.clone()) Some(self.editor.clone())
@ -7909,8 +7909,8 @@ impl Element for EditorElement {
self.editor.update(cx, |editor, cx| { self.editor.update(cx, |editor, cx| {
editor.set_style(self.style.clone(), window, cx); editor.set_style(self.style.clone(), window, cx);
let layout_id = match editor.mode { let layout_id = match editor.display_mode {
EditorMode::SingleLine => { EditorDisplayMode::SingleLine => {
let rem_size = window.rem_size(); let rem_size = window.rem_size();
let height = self.style.text.line_height_in_pixels(rem_size); let height = self.style.text.line_height_in_pixels(rem_size);
let mut style = Style::default(); let mut style = Style::default();
@ -7918,7 +7918,7 @@ impl Element for EditorElement {
style.size.width = relative(1.).into(); style.size.width = relative(1.).into();
window.request_layout(style, None, cx) window.request_layout(style, None, cx)
} }
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines, min_lines,
max_lines, max_lines,
} => { } => {
@ -7945,13 +7945,13 @@ impl Element for EditorElement {
}, },
) )
} }
EditorMode::Minimap { .. } => { EditorDisplayMode::Minimap { .. } => {
let mut style = Style::default(); let mut style = Style::default();
style.size.width = relative(1.).into(); style.size.width = relative(1.).into();
style.size.height = relative(1.).into(); style.size.height = relative(1.).into();
window.request_layout(style, None, cx) window.request_layout(style, None, cx)
} }
EditorMode::Full { EditorDisplayMode::Full {
sized_by_content, .. sized_by_content, ..
} => { } => {
let mut style = Style::default(); let mut style = Style::default();
@ -7990,7 +7990,7 @@ impl Element for EditorElement {
..Default::default() ..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 { if !is_minimap {
let focus_handle = self.editor.focus_handle(cx); 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); editor.set_visible_column_count(editor_width / em_advance);
if matches!( if matches!(
editor.mode, editor.display_mode,
EditorMode::AutoHeight { .. } | EditorMode::Minimap { .. } EditorDisplayMode::AutoHeight { .. }
| EditorDisplayMode::Minimap { .. }
) { ) {
snapshot snapshot
} else { } else {
@ -8112,10 +8113,10 @@ impl Element for EditorElement {
// The max scroll position for the top of the window // The max scroll position for the top of the window
let max_scroll_top = if matches!( let max_scroll_top = if matches!(
snapshot.mode, snapshot.display_mode,
EditorMode::SingleLine EditorDisplayMode::SingleLine
| EditorMode::AutoHeight { .. } | EditorDisplayMode::AutoHeight { .. }
| EditorMode::Full { | EditorDisplayMode::Full {
sized_by_content: true, sized_by_content: true,
.. ..
} }
@ -8980,7 +8981,7 @@ impl Element for EditorElement {
None, None,
); );
let mode = snapshot.mode.clone(); let mode = snapshot.display_mode.clone();
let (diff_hunk_controls, diff_hunk_control_bounds) = if is_read_only { let (diff_hunk_controls, diff_hunk_control_bounds) = if is_read_only {
(vec![], vec![]) (vec![], vec![])
@ -9209,7 +9210,7 @@ pub struct EditorLayout {
content_origin: gpui::Point<Pixels>, content_origin: gpui::Point<Pixels>,
scrollbars_layout: Option<EditorScrollbars>, scrollbars_layout: Option<EditorScrollbars>,
minimap: Option<MinimapLayout>, minimap: Option<MinimapLayout>,
mode: EditorMode, mode: EditorDisplayMode,
wrap_guides: SmallVec<[(Pixels, bool); 2]>, wrap_guides: SmallVec<[(Pixels, bool); 2]>,
indent_guides: Option<Vec<IndentGuideLayout>>, indent_guides: Option<Vec<IndentGuideLayout>>,
visible_display_row_range: Range<DisplayRow>, visible_display_row_range: Range<DisplayRow>,
@ -9788,7 +9789,7 @@ pub fn layout_line(
style, style,
MAX_LINE_LEN, MAX_LINE_LEN,
1, 1,
&snapshot.mode, &snapshot.display_mode,
text_width, text_width,
is_row_soft_wrapped, is_row_soft_wrapped,
window, window,
@ -10197,7 +10198,7 @@ mod tests {
let window = cx.add_window(|window, cx| { let window = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), cx); let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), cx);
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: None, max_lines: None,
}, },
@ -10233,7 +10234,7 @@ mod tests {
let window = cx.add_window(|window, cx| { let window = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple(&"a ".to_string().repeat(100), 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.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);
editor editor
}); });
@ -10260,7 +10261,7 @@ mod tests {
init_test(cx, |_| {}); init_test(cx, |_| {});
let window = cx.add_window(|window, cx| { let window = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), 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(); let editor = window.root(cx).unwrap();
@ -10361,7 +10362,7 @@ mod tests {
let window = cx.add_window(|window, cx| { let window = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple(&(sample_text(6, 6, 'a') + "\n"), 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 cx = &mut VisualTestContext::from_window(*window, cx);
let editor = window.root(cx).unwrap(); let editor = window.root(cx).unwrap();
@ -10432,7 +10433,7 @@ mod tests {
let window = cx.add_window(|window, cx| { let window = cx.add_window(|window, cx| {
let buffer = MultiBuffer::build_simple("", 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 cx = &mut VisualTestContext::from_window(*window, cx);
let editor = window.root(cx).unwrap(); let editor = window.root(cx).unwrap();
@ -10518,7 +10519,7 @@ mod tests {
let actual_invisibles = collect_invisibles_from_new_editor( let actual_invisibles = collect_invisibles_from_new_editor(
cx, cx,
EditorMode::full(), EditorDisplayMode::full(),
input_text, input_text,
px(500.0), px(500.0),
show_line_numbers, show_line_numbers,
@ -10536,8 +10537,8 @@ mod tests {
}); });
for editor_mode_without_invisibles in [ for editor_mode_without_invisibles in [
EditorMode::SingleLine, EditorDisplayMode::SingleLine,
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(100), max_lines: Some(100),
}, },
@ -10615,7 +10616,7 @@ mod tests {
let actual_invisibles = collect_invisibles_from_new_editor( let actual_invisibles = collect_invisibles_from_new_editor(
cx, cx,
EditorMode::full(), EditorDisplayMode::full(),
&input_text, &input_text,
px(editor_width), px(editor_width),
show_line_numbers, show_line_numbers,
@ -10654,7 +10655,7 @@ mod tests {
fn collect_invisibles_from_new_editor( fn collect_invisibles_from_new_editor(
cx: &mut TestAppContext, cx: &mut TestAppContext,
editor_mode: EditorMode, editor_mode: EditorDisplayMode,
input_text: &str, input_text: &str,
editor_width: Pixels, editor_width: Pixels,
show_line_numbers: bool, show_line_numbers: bool,

View file

@ -1267,7 +1267,7 @@ impl SerializableItem for Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Option<Task<Result<()>>> { ) -> Option<Task<Result<()>>> {
if self.mode.is_minimap() { if self.display_mode.is_minimap() {
return None; return None;
} }
let mut serialize_dirty_buffers = self.serialize_dirty_buffers; let mut serialize_dirty_buffers = self.serialize_dirty_buffers;
@ -1424,7 +1424,7 @@ impl Editor {
cx: &mut Context<Self>, cx: &mut Context<Self>,
write: impl for<'a> FnOnce(&'a mut RestorationData) + 'static, 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; return;
} }

View file

@ -150,7 +150,7 @@ impl Editor {
_: &Window, _: &Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if !self.mode().is_full() { if !self.display_mode().is_full() {
return; return;
} }
let Some(project) = self.project.clone() else { let Some(project) = self.project.clone() else {

View file

@ -153,7 +153,7 @@ pub fn deploy_context_menu(
} }
// Don't show context menu for inline editors // Don't show context menu for inline editors
if !editor.mode().is_full() { if !editor.display_mode().is_full() {
return; return;
} }

View file

@ -4,7 +4,7 @@ pub(crate) mod scroll_amount;
use crate::editor_settings::ScrollBeyondLastLine; use crate::editor_settings::ScrollBeyondLastLine;
use crate::{ use crate::{
Anchor, DisplayPoint, DisplayRow, Editor, EditorEvent, EditorMode, EditorSettings, Anchor, DisplayPoint, DisplayRow, Editor, EditorDisplayMode, EditorEvent, EditorSettings,
InlayHintRefreshReason, MultiBufferSnapshot, RowExt, ToPoint, InlayHintRefreshReason, MultiBufferSnapshot, RowExt, ToPoint,
display_map::{DisplaySnapshot, ToDisplayPoint}, display_map::{DisplaySnapshot, ToDisplayPoint},
hover_popover::hide_hover, hover_popover::hide_hover,
@ -675,7 +675,7 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }

View file

@ -1,6 +1,6 @@
use super::Axis; use super::Axis;
use crate::{ use crate::{
Autoscroll, Editor, EditorMode, NextScreen, NextScrollCursorCenterTopBottom, Autoscroll, Editor, EditorDisplayMode, NextScreen, NextScrollCursorCenterTopBottom,
SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT, ScrollCursorBottom, ScrollCursorCenter, SCROLL_CENTER_TOP_BOTTOM_DEBOUNCE_TIMEOUT, ScrollCursorBottom, ScrollCursorCenter,
ScrollCursorCenterTopBottom, ScrollCursorTop, display_map::DisplayRow, ScrollCursorCenterTopBottom, ScrollCursorTop, display_map::DisplayRow,
}; };
@ -16,7 +16,7 @@ impl Editor {
return; return;
} }
if matches!(self.mode, EditorMode::SingleLine) { if matches!(self.display_mode, EditorDisplayMode::SingleLine) {
cx.propagate(); cx.propagate();
return; return;
} }

View file

@ -1,5 +1,5 @@
use crate::{ use crate::{
DisplayRow, Editor, EditorMode, LineWithInvisibles, RowExt, SelectionEffects, DisplayRow, Editor, EditorDisplayMode, LineWithInvisibles, RowExt, SelectionEffects,
display_map::ToDisplayPoint, scroll::WasScrolled, display_map::ToDisplayPoint, scroll::WasScrolled,
}; };
use gpui::{Bounds, Context, Pixels, Window, px}; 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. 0.
} else { } else {
((visible_lines - (target_bottom - target_top)) / 2.0).floor() ((visible_lines - (target_bottom - target_top)) / 2.0).floor()

View file

@ -5,7 +5,7 @@ use std::{rc::Rc, sync::LazyLock};
pub use crate::rust_analyzer_ext::expand_macro_recursively; pub use crate::rust_analyzer_ext::expand_macro_recursively;
use crate::{ use crate::{
DisplayPoint, Editor, EditorMode, FoldPlaceholder, MultiBuffer, SelectionEffects, DisplayPoint, Editor, EditorDisplayMode, FoldPlaceholder, MultiBuffer, SelectionEffects,
display_map::{ display_map::{
Block, BlockPlacement, CustomBlockId, DisplayMap, DisplayRow, DisplaySnapshot, Block, BlockPlacement, CustomBlockId, DisplayMap, DisplayRow, DisplaySnapshot,
ToDisplayPoint, ToDisplayPoint,
@ -121,7 +121,7 @@ pub(crate) fn build_editor(
window: &mut Window, window: &mut Window,
cx: &mut Context<Editor>, cx: &mut Context<Editor>,
) -> 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( pub(crate) fn build_editor_with_project(
@ -130,7 +130,7 @@ pub(crate) fn build_editor_with_project(
window: &mut Window, window: &mut Window,
cx: &mut Context<Editor>, cx: &mut Context<Editor>,
) -> Editor { ) -> Editor {
Editor::new(EditorMode::full(), buffer, Some(project), window, cx) Editor::new(EditorDisplayMode::full(), buffer, Some(project), window, cx)
} }
#[derive(Default)] #[derive(Default)]

View file

@ -44,7 +44,7 @@ impl editor::Addon for ConflictAddon {
pub fn register_editor(editor: &mut Editor, buffer: Entity<MultiBuffer>, cx: &mut Context<Editor>) { 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. // 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).is_singleton()
&& !editor.buffer().read(cx).all_diff_hunks_expanded()) && !editor.buffer().read(cx).all_diff_hunks_expanded())
{ {

View file

@ -14,7 +14,7 @@ use anyhow::Context as _;
use askpass::AskPassDelegate; use askpass::AskPassDelegate;
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use editor::{ use editor::{
Editor, EditorElement, EditorMode, EditorSettings, MultiBuffer, ShowScrollbar, Editor, EditorDisplayMode, EditorElement, EditorSettings, MultiBuffer, ShowScrollbar,
scroll::ScrollbarAutoHide, scroll::ScrollbarAutoHide,
}; };
use futures::StreamExt as _; 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 buffer = cx.new(|cx| MultiBuffer::singleton(commit_message_buffer, cx));
let max_lines = if in_panel { MAX_PANEL_EDITOR_LINES } else { 18 }; let max_lines = if in_panel { MAX_PANEL_EDITOR_LINES } else { 18 };
let mut commit_editor = Editor::new( let mut commit_editor = Editor::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(max_lines), max_lines: Some(max_lines),
}, },

View file

@ -104,14 +104,14 @@ impl CursorPosition {
cursor_position.update(cx, |cursor_position, cx| { cursor_position.update(cx, |cursor_position, cx| {
cursor_position.selected_count = SelectionStats::default(); cursor_position.selected_count = SelectionStats::default();
cursor_position.selected_count.selections = editor.selections.count(); cursor_position.selected_count.selections = editor.selections.count();
match editor.mode() { match editor.display_mode() {
editor::EditorMode::AutoHeight { .. } editor::EditorDisplayMode::AutoHeight { .. }
| editor::EditorMode::SingleLine | editor::EditorDisplayMode::SingleLine
| editor::EditorMode::Minimap { .. } => { | editor::EditorDisplayMode::Minimap { .. } => {
cursor_position.position = None; cursor_position.position = None;
cursor_position.context = None; cursor_position.context = None;
} }
editor::EditorMode::Full { .. } => { editor::EditorDisplayMode::Full { .. } => {
let mut last_selection = None::<Selection<Point>>; let mut last_selection = None::<Selection<Point>>;
let snapshot = editor.buffer().read(cx).snapshot(cx); let snapshot = editor.buffer().read(cx).snapshot(cx);
if snapshot.excerpts().count() > 0 { if snapshot.excerpts().count() > 0 {

View file

@ -1,6 +1,6 @@
use anyhow::{Result, anyhow}; use anyhow::{Result, anyhow};
use editor::{ use editor::{
Bias, CompletionProvider, Editor, EditorEvent, EditorMode, ExcerptId, MinimapVisibility, Bias, CompletionProvider, Editor, EditorDisplayMode, EditorEvent, ExcerptId, MinimapVisibility,
MultiBuffer, MultiBuffer,
}; };
use fuzzy::StringMatch; use fuzzy::StringMatch;
@ -483,7 +483,7 @@ impl DivInspector {
cx.new(|cx| { cx.new(|cx| {
let multi_buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx)); let multi_buffer = cx.new(|cx| MultiBuffer::singleton(buffer, cx));
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::full(), EditorDisplayMode::full(),
multi_buffer, multi_buffer,
Some(self.project.clone()), Some(self.project.clone()),
window, window,

View file

@ -88,7 +88,7 @@ impl Render for OutlineView {
impl OutlineView { impl OutlineView {
fn register(editor: &mut Editor, _: Option<&mut Window>, cx: &mut Context<Editor>) { 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(); let handle = cx.entity().downgrade();
editor editor
.register_action(move |action, window, cx| { .register_action(move |action, window, cx| {

View file

@ -4949,7 +4949,7 @@ fn workspace_active_editor(
let active_item = workspace.active_item(cx)?; let active_item = workspace.active_item(cx)?;
let active_editor = active_item let active_editor = active_item
.act_as::<Editor>(cx) .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)) Some((active_item, active_editor))
} }

View file

@ -1,7 +1,7 @@
#![allow(unused, dead_code)] #![allow(unused, dead_code)]
use std::sync::Arc; use std::sync::Arc;
use editor::{Editor, EditorMode, MultiBuffer}; use editor::{Editor, EditorDisplayMode, MultiBuffer};
use futures::future::Shared; use futures::future::Shared;
use gpui::{ use gpui::{
App, Entity, Hsla, RetainAllImageCache, Task, TextStyleRefinement, image_cache, prelude::*, App, Entity, Hsla, RetainAllImageCache, Task, TextStyleRefinement, image_cache, prelude::*,
@ -177,7 +177,7 @@ impl Cell {
let editor_view = cx.new(|cx| { let editor_view = cx.new(|cx| {
let mut editor = Editor::new( let mut editor = Editor::new(
EditorMode::AutoHeight { EditorDisplayMode::AutoHeight {
min_lines: 1, min_lines: 1,
max_lines: Some(1024), max_lines: Some(1024),
}, },

View file

@ -2699,7 +2699,7 @@ impl ActionArgumentsEditor {
let editor = cx.new_window_entity(|window, cx| { let editor = cx.new_window_entity(|window, cx| {
let multi_buffer = cx.new(|cx| editor::MultiBuffer::singleton(buffer, cx)); let multi_buffer = cx.new(|cx| editor::MultiBuffer::singleton(buffer, cx));
let mut editor = Editor::new( let mut editor = Editor::new(
editor::EditorMode::Full { editor::EditorDisplayMode::Full {
scale_ui_elements_with_buffer_font_size: true, scale_ui_elements_with_buffer_font_size: true,
show_active_line_background: false, show_active_line_background: false,
sized_by_content: true, sized_by_content: true,

View file

@ -7,7 +7,7 @@ use std::time::Duration;
use collections::HashMap; use collections::HashMap;
use command_palette::CommandPalette; use command_palette::CommandPalette;
use editor::{ use editor::{
AnchorRangeExt, DisplayPoint, Editor, EditorMode, MultiBuffer, actions::DeleteLine, AnchorRangeExt, DisplayPoint, Editor, EditorDisplayMode, MultiBuffer, actions::DeleteLine,
display_map::DisplayRow, test::editor_test_context::EditorTestContext, display_map::DisplayRow, test::editor_test_context::EditorTestContext,
}; };
use futures::StreamExt; use futures::StreamExt;
@ -1784,7 +1784,13 @@ async fn test_folded_multibuffer_excerpts(cx: &mut gpui::TestAppContext) {
], ],
cx, 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(); let buffer_ids = multi_buffer.read(cx).excerpt_buffer_ids();
// fold all but the second buffer, so that we test navigating between two // fold all but the second buffer, so that we test navigating between two

View file

@ -1222,7 +1222,7 @@ impl Vim {
editor.selections.newest::<usize>(cx).is_empty() editor.selections.newest::<usize>(cx).is_empty()
}); });
let editor = editor.read(cx); let editor = editor.read(cx);
let editor_mode = editor.mode(); let editor_mode = editor.display_mode();
if editor_mode.is_full() if editor_mode.is_full()
&& !newest_selection_empty && !newest_selection_empty

View file

@ -18,7 +18,7 @@ pub fn init(client: Arc<Client>, user_store: Entity<UserStore>, cx: &mut App) {
let client = client.clone(); let client = client.clone();
let user_store = user_store.clone(); let user_store = user_store.clone();
move |editor: &mut Editor, window, cx: &mut Context<Editor>| { move |editor: &mut Editor, window, cx: &mut Context<Editor>| {
if !editor.mode().is_full() { if !editor.display_mode().is_full() {
return; return;
} }

View file

@ -119,7 +119,7 @@ impl Render for QuickActionBar {
let selection_menu_enabled = editor_value.selection_menu_enabled(cx); let selection_menu_enabled = editor_value.selection_menu_enabled(cx);
let inlay_hints_enabled = editor_value.inlay_hints_enabled(); let inlay_hints_enabled = editor_value.inlay_hints_enabled();
let inline_values_enabled = editor_value.inline_values_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 diagnostics_enabled = editor_value.diagnostics_max_severity != DiagnosticSeverity::Off;
let supports_inline_diagnostics = editor_value.inline_diagnostics_enabled(); let supports_inline_diagnostics = editor_value.inline_diagnostics_enabled();
let inline_diagnostics_enabled = editor_value.show_inline_diagnostics(); let inline_diagnostics_enabled = editor_value.show_inline_diagnostics();