|
|
|
@ -9,7 +9,7 @@ use helix_lsp::{
|
|
|
|
|
use helix_stdx::path::get_relative_path;
|
|
|
|
|
use helix_view::{
|
|
|
|
|
align_view,
|
|
|
|
|
document::DocumentSavedEventResult,
|
|
|
|
|
document::{DocumentSavedEventResult, IrregularFileError},
|
|
|
|
|
editor::{ConfigEvent, EditorEvent},
|
|
|
|
|
graphics::Rect,
|
|
|
|
|
theme,
|
|
|
|
@ -186,9 +186,17 @@ impl Application {
|
|
|
|
|
Some(Layout::Horizontal) => Action::HorizontalSplit,
|
|
|
|
|
None => Action::Load,
|
|
|
|
|
};
|
|
|
|
|
let doc_id = editor
|
|
|
|
|
let doc_id = match editor
|
|
|
|
|
.open(&file, action)
|
|
|
|
|
.context(format!("open '{}'", file.to_string_lossy()))?;
|
|
|
|
|
.context(format!("open '{}'", file.to_string_lossy()))
|
|
|
|
|
{
|
|
|
|
|
// Ignore irregular files during application init.
|
|
|
|
|
Err(e) if e.is::<IrregularFileError>() => {
|
|
|
|
|
nr_of_files -= 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
a => a,
|
|
|
|
|
}?;
|
|
|
|
|
// with Action::Load all documents have the same view
|
|
|
|
|
// NOTE: this isn't necessarily true anymore. If
|
|
|
|
|
// `--vsplit` or `--hsplit` are used, the file which is
|
|
|
|
@ -199,15 +207,21 @@ impl Application {
|
|
|
|
|
doc.set_selection(view_id, pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
editor.set_status(format!(
|
|
|
|
|
"Loaded {} file{}.",
|
|
|
|
|
nr_of_files,
|
|
|
|
|
if nr_of_files == 1 { "" } else { "s" } // avoid "Loaded 1 files." grammo
|
|
|
|
|
));
|
|
|
|
|
// align the view to center after all files are loaded,
|
|
|
|
|
// does not affect views without pos since it is at the top
|
|
|
|
|
let (view, doc) = current!(editor);
|
|
|
|
|
align_view(doc, view, Align::Center);
|
|
|
|
|
|
|
|
|
|
// if all files were invalid, replace with empty buffer
|
|
|
|
|
if nr_of_files == 0 {
|
|
|
|
|
editor.new_file(Action::VerticalSplit);
|
|
|
|
|
} else {
|
|
|
|
|
editor.set_status(format!(
|
|
|
|
|
"Loaded {} file{}.",
|
|
|
|
|
nr_of_files,
|
|
|
|
|
if nr_of_files == 1 { "" } else { "s" } // avoid "Loaded 1 files." grammo
|
|
|
|
|
));
|
|
|
|
|
// align the view to center after all files are loaded,
|
|
|
|
|
// does not affect views without pos since it is at the top
|
|
|
|
|
let (view, doc) = current!(editor);
|
|
|
|
|
align_view(doc, view, Align::Center);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
editor.new_file(Action::VerticalSplit);
|
|
|
|
|
}
|
|
|
|
|