fix: surface rejected configuration in a floating startup diagnostic
This commit is contained in:
@@ -62,6 +62,13 @@ pub struct Palette {
|
||||
pub selected: usize,
|
||||
}
|
||||
|
||||
pub struct StartupDiagnostic {
|
||||
pub lines: Vec<String>,
|
||||
pub top: usize,
|
||||
pub left: usize,
|
||||
max_column: usize,
|
||||
}
|
||||
|
||||
pub struct Hover {
|
||||
text: String,
|
||||
line_starts: Vec<usize>,
|
||||
@@ -878,6 +885,7 @@ pub struct Editor {
|
||||
leader_display: String,
|
||||
palette: Option<Palette>,
|
||||
hover: Option<Hover>,
|
||||
startup_diagnostic: Option<StartupDiagnostic>,
|
||||
project_root: PathBuf,
|
||||
file_picker: Option<FilePicker>,
|
||||
file_explorer_side: DockSide,
|
||||
@@ -936,6 +944,7 @@ impl Editor {
|
||||
leader_display: String::new(),
|
||||
palette: None,
|
||||
hover: None,
|
||||
startup_diagnostic: None,
|
||||
project_root: std::env::current_dir()?,
|
||||
file_picker: None,
|
||||
file_explorer_side: DockSide::Right,
|
||||
@@ -1217,6 +1226,25 @@ impl Editor {
|
||||
self.palette.as_ref()
|
||||
}
|
||||
|
||||
pub fn startup_diagnostic(&self) -> Option<&StartupDiagnostic> {
|
||||
self.startup_diagnostic.as_ref()
|
||||
}
|
||||
|
||||
pub(crate) fn show_startup_diagnostic(&mut self, text: String) {
|
||||
let lines = split_lines(&text);
|
||||
let max_column = lines
|
||||
.iter()
|
||||
.map(|line| line.graphemes(true).count())
|
||||
.max()
|
||||
.unwrap_or(0);
|
||||
self.startup_diagnostic = Some(StartupDiagnostic {
|
||||
lines,
|
||||
top: 0,
|
||||
left: 0,
|
||||
max_column,
|
||||
});
|
||||
}
|
||||
|
||||
/// Borrowed popup state, visible only while its source remains current.
|
||||
pub fn hover(&self) -> Option<&Hover> {
|
||||
self.hover.as_ref().filter(|hover| {
|
||||
@@ -1981,6 +2009,30 @@ impl Editor {
|
||||
Input::Ctrl(ch) => control_key(ch),
|
||||
input => input,
|
||||
};
|
||||
if let Some(diagnostic) = &mut self.startup_diagnostic {
|
||||
match input {
|
||||
Input::Enter | Input::Escape => self.startup_diagnostic = None,
|
||||
Input::Up | Input::Ctrl('k') => diagnostic.top = diagnostic.top.saturating_sub(1),
|
||||
Input::Down | Input::Ctrl('j') => {
|
||||
diagnostic.top = diagnostic
|
||||
.top
|
||||
.saturating_add(1)
|
||||
.min(diagnostic.lines.len() - 1)
|
||||
}
|
||||
Input::Left | Input::Ctrl('h') => {
|
||||
diagnostic.left = diagnostic.left.saturating_sub(1)
|
||||
}
|
||||
Input::Right | Input::Ctrl('l') => {
|
||||
diagnostic.left = diagnostic.left.saturating_add(1).min(diagnostic.max_column)
|
||||
}
|
||||
Input::Home => {
|
||||
diagnostic.top = 0;
|
||||
diagnostic.left = 0;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
if self.handle_hover(&input) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user