From 34c6094604cfeca0c1338a20cf9e85bcd8d9b68b Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Tue, 24 Aug 2021 11:32:44 +0300 Subject: [PATCH] refactor --- Cargo.lock | 1 - helix-dap/src/client.rs | 4 +--- helix-term/Cargo.toml | 2 -- helix-term/src/application.rs | 15 +++++++-------- helix-term/src/commands.rs | 6 +----- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f1dfa10f..6f991060e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,7 +390,6 @@ dependencies = [ "serde_json", "signal-hook", "signal-hook-tokio", - "smallvec", "tokio", "tokio-stream", "toml", diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index 43afc4c61..ed4f8ed50 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -225,9 +225,7 @@ async fn request( } pub fn capabilities(&self) -> &DebuggerCapabilities { - self.caps - .as_ref() - .expect("debugger not yet initialized!") + self.caps.as_ref().expect("debugger not yet initialized!") } pub async fn initialize(&mut self, adapter_id: String) -> Result<()> { diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index 638565850..c0b2cfe56 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -56,7 +56,5 @@ toml = "0.5" serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -smallvec = "1.4" - [target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100 signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] } diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 72f3a1259..3f9111956 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -13,7 +13,6 @@ }; use log::error; -use smallvec::smallvec; use std::{ io::{stdout, Write}, sync::Arc, @@ -305,20 +304,17 @@ pub async fn handle_debugger_message(&mut self, payload: helix_dap::Payload) { if let Some(helix_dap::StackFrame { source: Some(helix_dap::Source { - path: Some(src), .. + path: Some(ref src), + .. }), line, column, end_line, end_column, .. - }) = &debugger.stack_pointer + }) = debugger.stack_pointer { let path = src.clone(); - let line = *line; - let column = *column; - let end_line = *end_line; - let end_column = *end_column; self.editor .open(path, helix_view::editor::Action::Replace) .unwrap(); @@ -333,7 +329,10 @@ pub async fn handle_debugger_message(&mut self, payload: helix_dap::Payload) { doc.set_selection( view.id, Selection::new( - smallvec![Range::new(start.min(text_end), end.min(text_end))], + helix_core::SmallVec::from_vec(vec![Range::new( + start.min(text_end), + end.min(text_end), + )]), 0, ), ); diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 74466e7ee..8c1cd5d83 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4422,11 +4422,7 @@ fn dap_start(cx: &mut Context) { let request = debugger.initialize(config.name); let _ = block_on(request).unwrap(); - let sessions = cx - .editor - .syn_loader - .language_config_for_file_name(&path) - .and_then(|x| x.debug_configs.clone()); + let sessions = doc.language_config().and_then(|x| x.debug_configs.clone()); let sessions = match sessions { Some(c) => c,