Future-proof indent guides settings for panels (#19878)
This PR ensures that we do not have to break the indent guides settings for the project/outline panel. In the future we might want to have a more granular way to control when to show indent guides, or control other indent guide properties, like its width. Release Notes: - N/A
This commit is contained in:
parent
719a7f7890
commit
b5c41eeb98
6 changed files with 117 additions and 34 deletions
|
@ -35,7 +35,7 @@ use itertools::Itertools;
|
|||
use language::{BufferId, BufferSnapshot, OffsetRangeExt, OutlineItem};
|
||||
use menu::{Cancel, SelectFirst, SelectLast, SelectNext, SelectPrev};
|
||||
|
||||
use outline_panel_settings::{OutlinePanelDockPosition, OutlinePanelSettings};
|
||||
use outline_panel_settings::{OutlinePanelDockPosition, OutlinePanelSettings, ShowIndentGuides};
|
||||
use project::{File, Fs, Item, Project};
|
||||
use search::{BufferSearchBar, ProjectSearchView};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -3748,7 +3748,7 @@ impl Render for OutlinePanel {
|
|||
let pinned = self.pinned;
|
||||
let settings = OutlinePanelSettings::get_global(cx);
|
||||
let indent_size = settings.indent_size;
|
||||
let show_indent_guides = settings.indent_guides;
|
||||
let show_indent_guides = settings.indent_guides.show == ShowIndentGuides::Always;
|
||||
|
||||
let outline_panel = v_flex()
|
||||
.id("outline-panel")
|
||||
|
|
|
@ -10,6 +10,13 @@ pub enum OutlinePanelDockPosition {
|
|||
Right,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ShowIndentGuides {
|
||||
Always,
|
||||
Never,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
|
||||
pub struct OutlinePanelSettings {
|
||||
pub button: bool,
|
||||
|
@ -19,11 +26,22 @@ pub struct OutlinePanelSettings {
|
|||
pub folder_icons: bool,
|
||||
pub git_status: bool,
|
||||
pub indent_size: f32,
|
||||
pub indent_guides: bool,
|
||||
pub indent_guides: IndentGuidesSettings,
|
||||
pub auto_reveal_entries: bool,
|
||||
pub auto_fold_dirs: bool,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
pub struct IndentGuidesSettings {
|
||||
pub show: ShowIndentGuides,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
pub struct IndentGuidesSettingsContent {
|
||||
/// When to show the scrollbar in the outline panel.
|
||||
pub show: Option<ShowIndentGuides>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
||||
pub struct OutlinePanelSettingsContent {
|
||||
/// Whether to show the outline panel button in the status bar.
|
||||
|
@ -54,10 +72,6 @@ pub struct OutlinePanelSettingsContent {
|
|||
///
|
||||
/// Default: 20
|
||||
pub indent_size: Option<f32>,
|
||||
/// Whether to show indent guides in the outline panel.
|
||||
///
|
||||
/// Default: true
|
||||
pub indent_guides: Option<bool>,
|
||||
/// Whether to reveal it in the outline panel automatically,
|
||||
/// when a corresponding project entry becomes active.
|
||||
/// Gitignored entries are never auto revealed.
|
||||
|
@ -69,6 +83,8 @@ pub struct OutlinePanelSettingsContent {
|
|||
///
|
||||
/// Default: true
|
||||
pub auto_fold_dirs: Option<bool>,
|
||||
/// Settings related to indent guides in the outline panel.
|
||||
pub indent_guides: Option<IndentGuidesSettingsContent>,
|
||||
}
|
||||
|
||||
impl Settings for OutlinePanelSettings {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue