Hide assistant gutter
This commit is contained in:
parent
8f6e67f440
commit
3904971bd8
7 changed files with 38 additions and 3 deletions
|
@ -15,7 +15,6 @@ use std::cell::RefCell;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::{io, sync::Arc};
|
use std::{io, sync::Arc};
|
||||||
use util::channel::{ReleaseChannel, RELEASE_CHANNEL};
|
|
||||||
use util::{ResultExt, TryFutureExt};
|
use util::{ResultExt, TryFutureExt};
|
||||||
|
|
||||||
pub use assistant::AssistantPanel;
|
pub use assistant::AssistantPanel;
|
||||||
|
|
|
@ -235,6 +235,7 @@ impl ContextEditor {
|
||||||
let editor = cx.add_view(|cx| {
|
let editor = cx.add_view(|cx| {
|
||||||
let mut editor = Editor::for_multibuffer(multibuffer, None, cx);
|
let mut editor = Editor::for_multibuffer(multibuffer, None, cx);
|
||||||
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
|
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
|
||||||
|
editor.set_show_gutter(false, cx);
|
||||||
editor
|
editor
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -328,7 +329,12 @@ impl View for ContextEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||||
ChildView::new(&self.editor, cx).into_any()
|
let theme = &theme::current(cx).assistant;
|
||||||
|
|
||||||
|
ChildView::new(&self.editor, cx)
|
||||||
|
.contained()
|
||||||
|
.with_style(theme.container)
|
||||||
|
.into_any()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -496,6 +496,7 @@ pub struct Editor {
|
||||||
blink_manager: ModelHandle<BlinkManager>,
|
blink_manager: ModelHandle<BlinkManager>,
|
||||||
show_local_selections: bool,
|
show_local_selections: bool,
|
||||||
mode: EditorMode,
|
mode: EditorMode,
|
||||||
|
show_gutter: bool,
|
||||||
placeholder_text: Option<Arc<str>>,
|
placeholder_text: Option<Arc<str>>,
|
||||||
highlighted_rows: Option<Range<u32>>,
|
highlighted_rows: Option<Range<u32>>,
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
@ -526,6 +527,7 @@ pub struct Editor {
|
||||||
|
|
||||||
pub struct EditorSnapshot {
|
pub struct EditorSnapshot {
|
||||||
pub mode: EditorMode,
|
pub mode: EditorMode,
|
||||||
|
pub show_gutter: bool,
|
||||||
pub display_snapshot: DisplaySnapshot,
|
pub display_snapshot: DisplaySnapshot,
|
||||||
pub placeholder_text: Option<Arc<str>>,
|
pub placeholder_text: Option<Arc<str>>,
|
||||||
is_focused: bool,
|
is_focused: bool,
|
||||||
|
@ -1297,6 +1299,7 @@ impl Editor {
|
||||||
blink_manager: blink_manager.clone(),
|
blink_manager: blink_manager.clone(),
|
||||||
show_local_selections: true,
|
show_local_selections: true,
|
||||||
mode,
|
mode,
|
||||||
|
show_gutter: mode == EditorMode::Full,
|
||||||
placeholder_text: None,
|
placeholder_text: None,
|
||||||
highlighted_rows: None,
|
highlighted_rows: None,
|
||||||
background_highlights: Default::default(),
|
background_highlights: Default::default(),
|
||||||
|
@ -1393,6 +1396,7 @@ impl Editor {
|
||||||
pub fn snapshot(&mut self, cx: &mut WindowContext) -> EditorSnapshot {
|
pub fn snapshot(&mut self, cx: &mut WindowContext) -> EditorSnapshot {
|
||||||
EditorSnapshot {
|
EditorSnapshot {
|
||||||
mode: self.mode,
|
mode: self.mode,
|
||||||
|
show_gutter: self.show_gutter,
|
||||||
display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)),
|
display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)),
|
||||||
scroll_anchor: self.scroll_manager.anchor(),
|
scroll_anchor: self.scroll_manager.anchor(),
|
||||||
ongoing_scroll: self.scroll_manager.ongoing_scroll(),
|
ongoing_scroll: self.scroll_manager.ongoing_scroll(),
|
||||||
|
@ -6654,6 +6658,11 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_show_gutter(&mut self, show_gutter: bool, cx: &mut ViewContext<Self>) {
|
||||||
|
self.show_gutter = show_gutter;
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
|
pub fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
|
||||||
if let Some(buffer) = self.buffer().read(cx).as_singleton() {
|
if let Some(buffer) = self.buffer().read(cx).as_singleton() {
|
||||||
if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
|
if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
|
||||||
|
|
|
@ -1899,7 +1899,7 @@ impl Element<Editor> for EditorElement {
|
||||||
let gutter_padding;
|
let gutter_padding;
|
||||||
let gutter_width;
|
let gutter_width;
|
||||||
let gutter_margin;
|
let gutter_margin;
|
||||||
if snapshot.mode == EditorMode::Full {
|
if snapshot.show_gutter {
|
||||||
let em_width = style.text.em_width(cx.font_cache());
|
let em_width = style.text.em_width(cx.font_cache());
|
||||||
gutter_padding = (em_width * style.gutter_padding_factor).round();
|
gutter_padding = (em_width * style.gutter_padding_factor).round();
|
||||||
gutter_width = self.max_line_number_width(&snapshot, cx) + gutter_padding * 2.0;
|
gutter_width = self.max_line_number_width(&snapshot, cx) + gutter_padding * 2.0;
|
||||||
|
|
|
@ -60,6 +60,7 @@ pub struct Theme {
|
||||||
pub incoming_call_notification: IncomingCallNotification,
|
pub incoming_call_notification: IncomingCallNotification,
|
||||||
pub tooltip: TooltipStyle,
|
pub tooltip: TooltipStyle,
|
||||||
pub terminal: TerminalStyle,
|
pub terminal: TerminalStyle,
|
||||||
|
pub assistant: AssistantStyle,
|
||||||
pub feedback: FeedbackStyle,
|
pub feedback: FeedbackStyle,
|
||||||
pub welcome: WelcomeStyle,
|
pub welcome: WelcomeStyle,
|
||||||
pub color_scheme: ColorScheme,
|
pub color_scheme: ColorScheme,
|
||||||
|
@ -967,6 +968,11 @@ pub struct TerminalStyle {
|
||||||
pub dim_foreground: Color,
|
pub dim_foreground: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Deserialize, Default)]
|
||||||
|
pub struct AssistantStyle {
|
||||||
|
pub container: ContainerStyle,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, Default)]
|
#[derive(Clone, Deserialize, Default)]
|
||||||
pub struct FeedbackStyle {
|
pub struct FeedbackStyle {
|
||||||
pub submit_button: Interactive<ContainedText>,
|
pub submit_button: Interactive<ContainedText>,
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { ColorScheme } from "../themes/common/colorScheme"
|
||||||
import feedback from "./feedback"
|
import feedback from "./feedback"
|
||||||
import welcome from "./welcome"
|
import welcome from "./welcome"
|
||||||
import copilot from "./copilot"
|
import copilot from "./copilot"
|
||||||
|
import assistant from "./assistant"
|
||||||
|
|
||||||
export default function app(colorScheme: ColorScheme): Object {
|
export default function app(colorScheme: ColorScheme): Object {
|
||||||
return {
|
return {
|
||||||
|
@ -50,6 +51,7 @@ export default function app(colorScheme: ColorScheme): Object {
|
||||||
simpleMessageNotification: simpleMessageNotification(colorScheme),
|
simpleMessageNotification: simpleMessageNotification(colorScheme),
|
||||||
tooltip: tooltip(colorScheme),
|
tooltip: tooltip(colorScheme),
|
||||||
terminal: terminal(colorScheme),
|
terminal: terminal(colorScheme),
|
||||||
|
assistant: assistant(colorScheme),
|
||||||
feedback: feedback(colorScheme),
|
feedback: feedback(colorScheme),
|
||||||
colorScheme: {
|
colorScheme: {
|
||||||
...colorScheme,
|
...colorScheme,
|
||||||
|
|
13
styles/src/styleTree/assistant.ts
Normal file
13
styles/src/styleTree/assistant.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import { ColorScheme } from "../themes/common/colorScheme"
|
||||||
|
import editor from "./editor"
|
||||||
|
|
||||||
|
export default function assistant(colorScheme: ColorScheme) {
|
||||||
|
return {
|
||||||
|
container: {
|
||||||
|
background: editor(colorScheme).background,
|
||||||
|
padding: {
|
||||||
|
left: 10,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue