Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jpttrssn committed Sep 3, 2024
1 parent c0868aa commit 9ec62f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
14 changes: 8 additions & 6 deletions helix-term/tests/test/lsp/code_actions_on_save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9ec62f8

Please sign in to comment.