aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/application.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-06 15:28:19 +0000
committerBlaž Hrastnik2021-11-06 15:28:19 +0000
commitf2b709a3c3a9cc036bfea46734efd7e4100eb34b (patch)
treead5f921f13659e5ba395442e13389af317ee81b0 /helix-term/src/application.rs
parentcde57dae356021c6ca8c2a2ed68777bd9d0bc0b2 (diff)
parentf979bdc442ab3150a369ff8bee0703e90e32e2a4 (diff)
Merge branch 'master' into debug
Diffstat (limited to 'helix-term/src/application.rs')
-rw-r--r--helix-term/src/application.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 27062a36..0fb4e479 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -99,12 +99,17 @@ impl Application {
let editor_view = Box::new(ui::EditorView::new(std::mem::take(&mut config.keys)));
compositor.push(editor_view);
- if !args.files.is_empty() {
+ if args.load_tutor {
+ let path = helix_core::runtime_dir().join("tutor.txt");
+ editor.open(path, Action::VerticalSplit)?;
+ // Unset path to prevent accidentally saving to the original tutor file.
+ doc_mut!(editor).set_path(None)?;
+ } else if !args.files.is_empty() {
let first = &args.files[0]; // we know it's not empty
if first.is_dir() {
std::env::set_current_dir(&first)?;
editor.new_file(Action::VerticalSplit);
- compositor.push(Box::new(ui::file_picker(first.clone())));
+ compositor.push(Box::new(ui::file_picker(".".into())));
} else {
let nr_of_files = args.files.len();
editor.open(first.to_path_buf(), Action::VerticalSplit)?;
@@ -240,7 +245,7 @@ impl Application {
}
pub fn handle_idle_timeout(&mut self) {
- use crate::commands::{completion, Context};
+ use crate::commands::{insert::idle_completion, Context};
use helix_view::document::Mode;
if doc_mut!(self.editor).mode != Mode::Insert || !self.config.editor.auto_completion {
@@ -267,7 +272,7 @@ impl Application {
callback: None,
on_next_key_callback: None,
};
- completion(&mut cx);
+ idle_completion(&mut cx);
self.render();
}
@@ -548,10 +553,11 @@ impl Application {
message: diagnostic.message,
severity: diagnostic.severity.map(
|severity| match severity {
- DiagnosticSeverity::Error => Error,
- DiagnosticSeverity::Warning => Warning,
- DiagnosticSeverity::Information => Info,
- DiagnosticSeverity::Hint => Hint,
+ DiagnosticSeverity::ERROR => Error,
+ DiagnosticSeverity::WARNING => Warning,
+ DiagnosticSeverity::INFORMATION => Info,
+ DiagnosticSeverity::HINT => Hint,
+ severity => unimplemented!("{:?}", severity),
},
),
// code
@@ -727,7 +733,9 @@ impl Application {
let mut stdout = stdout();
// reset cursor shape
write!(stdout, "\x1B[2 q")?;
- execute!(stdout, DisableMouseCapture)?;
+ // Ignore errors on disabling, this might trigger on windows if we call
+ // disable without calling enable previously
+ let _ = execute!(stdout, DisableMouseCapture);
execute!(stdout, terminal::LeaveAlternateScreen)?;
terminal::disable_raw_mode()?;
Ok(())