From ae5844af8c6ce4d6043cbf36b9e4bdee470cced9 Mon Sep 17 00:00:00 2001 From: Jonatan Pettersson Date: Tue, 3 Sep 2024 19:24:52 +0200 Subject: [PATCH] Code cleanup --- helix-term/src/commands/lsp.rs | 8 ++++---- helix-term/src/commands/typed.rs | 1 - helix-term/tests/test/lsp/code_actions_on_save.rs | 14 ++++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index 0d6d47992..9455d17b2 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -546,9 +546,9 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) { cx.push_layer(Box::new(overlaid(picker))); } -pub struct CodeActionOrCommandItem { - pub lsp_item: lsp::CodeActionOrCommand, - pub language_server_id: LanguageServerId, +struct CodeActionOrCommandItem { + lsp_item: lsp::CodeActionOrCommand, + language_server_id: LanguageServerId, } impl ui::menu::Item for CodeActionOrCommandItem { @@ -842,7 +842,7 @@ pub fn code_actions_on_save(cx: &mut compositor::Context, doc_id: &DocumentId) { } } -pub fn apply_code_action(editor: &mut Editor, action: &CodeActionOrCommandItem) { +fn apply_code_action(editor: &mut Editor, action: &CodeActionOrCommandItem) { let Some(language_server) = editor.language_server_by_id(action.language_server_id) else { editor.set_error("Language Server disappeared"); return; diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 98a307d86..586882106 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -12,7 +12,6 @@ use helix_core::{line_ending, shellwords::Shellwords}; use helix_view::document::{read_to_string, DEFAULT_LANGUAGE_NAME}; use helix_view::editor::{CloseError, ConfigEvent}; use serde_json::Value; - use ui::completers::{self, Completer}; #[derive(Clone)] diff --git a/helix-term/tests/test/lsp/code_actions_on_save.rs b/helix-term/tests/test/lsp/code_actions_on_save.rs index 51e3dbad1..fb8a0ebe0 100644 --- a/helix-term/tests/test/lsp/code_actions_on_save.rs +++ b/helix-term/tests/test/lsp/code_actions_on_save.rs @@ -9,6 +9,11 @@ use super::*; // Give time to send textDocument/didOpen notification const IDLE_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(500); +// Gopls does not use native line endings so set default line ending +// to LF to avoid issues in Windows tests. +const DEFAULT_LINE_ENDING: helix_view::editor::LineEndingConfig = + helix_view::editor::LineEndingConfig::LF; + // Check that we have gopls available while also allowing // for gopls to initialize fn assert_gopls(app: &Application, path: &Path) { @@ -22,9 +27,6 @@ fn assert_gopls(app: &Application, path: &Path) { if let Some(gopls) = ls { if gopls.is_initialized() { initialized = true; - // TODO: Make this deterministic - // Sleep to give time to send textDocument/didOpen notification - // std::thread::sleep(std::time::Duration::from_millis(IDLE_TIMEOUT)); break; } } @@ -74,7 +76,7 @@ async fn test_organize_imports_go() -> anyhow::Result<()> { .with_config(Config { editor: helix_view::editor::Config { idle_timeout: IDLE_TIMEOUT, - default_line_ending: helix_view::editor::LineEndingConfig::LF, + default_line_ending: DEFAULT_LINE_ENDING, ..Default::default() }, ..Default::default() @@ -134,7 +136,7 @@ async fn test_organize_imports_go_write_all_quit() -> anyhow::Result<()> { .with_config(Config { editor: helix_view::editor::Config { idle_timeout: IDLE_TIMEOUT, - default_line_ending: helix_view::editor::LineEndingConfig::LF, + default_line_ending: DEFAULT_LINE_ENDING, ..Default::default() }, ..Default::default() @@ -204,7 +206,7 @@ async fn test_invalid_code_action_go() -> anyhow::Result<()> { .with_config(Config { editor: helix_view::editor::Config { idle_timeout: IDLE_TIMEOUT, - default_line_ending: helix_view::editor::LineEndingConfig::LF, + default_line_ending: DEFAULT_LINE_ENDING, ..Default::default() }, ..Default::default()