Code cleanup

pull/6486/head
Jonatan Pettersson 3 months ago
parent 67eaf5cd55
commit ae5844af8c

@ -546,9 +546,9 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) {
cx.push_layer(Box::new(overlaid(picker))); cx.push_layer(Box::new(overlaid(picker)));
} }
pub struct CodeActionOrCommandItem { struct CodeActionOrCommandItem {
pub lsp_item: lsp::CodeActionOrCommand, lsp_item: lsp::CodeActionOrCommand,
pub language_server_id: LanguageServerId, language_server_id: LanguageServerId,
} }
impl ui::menu::Item for CodeActionOrCommandItem { 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 { let Some(language_server) = editor.language_server_by_id(action.language_server_id) else {
editor.set_error("Language Server disappeared"); editor.set_error("Language Server disappeared");
return; return;

@ -12,7 +12,6 @@ use helix_core::{line_ending, shellwords::Shellwords};
use helix_view::document::{read_to_string, DEFAULT_LANGUAGE_NAME}; use helix_view::document::{read_to_string, DEFAULT_LANGUAGE_NAME};
use helix_view::editor::{CloseError, ConfigEvent}; use helix_view::editor::{CloseError, ConfigEvent};
use serde_json::Value; use serde_json::Value;
use ui::completers::{self, Completer}; use ui::completers::{self, Completer};
#[derive(Clone)] #[derive(Clone)]

@ -9,6 +9,11 @@ use super::*;
// Give time to send textDocument/didOpen notification // Give time to send textDocument/didOpen notification
const IDLE_TIMEOUT: std::time::Duration = std::time::Duration::from_millis(500); 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 // Check that we have gopls available while also allowing
// for gopls to initialize // for gopls to initialize
fn assert_gopls(app: &Application, path: &Path) { fn assert_gopls(app: &Application, path: &Path) {
@ -22,9 +27,6 @@ fn assert_gopls(app: &Application, path: &Path) {
if let Some(gopls) = ls { if let Some(gopls) = ls {
if gopls.is_initialized() { if gopls.is_initialized() {
initialized = true; 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; break;
} }
} }
@ -74,7 +76,7 @@ async fn test_organize_imports_go() -> anyhow::Result<()> {
.with_config(Config { .with_config(Config {
editor: helix_view::editor::Config { editor: helix_view::editor::Config {
idle_timeout: IDLE_TIMEOUT, idle_timeout: IDLE_TIMEOUT,
default_line_ending: helix_view::editor::LineEndingConfig::LF, default_line_ending: DEFAULT_LINE_ENDING,
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
@ -134,7 +136,7 @@ async fn test_organize_imports_go_write_all_quit() -> anyhow::Result<()> {
.with_config(Config { .with_config(Config {
editor: helix_view::editor::Config { editor: helix_view::editor::Config {
idle_timeout: IDLE_TIMEOUT, idle_timeout: IDLE_TIMEOUT,
default_line_ending: helix_view::editor::LineEndingConfig::LF, default_line_ending: DEFAULT_LINE_ENDING,
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()
@ -204,7 +206,7 @@ async fn test_invalid_code_action_go() -> anyhow::Result<()> {
.with_config(Config { .with_config(Config {
editor: helix_view::editor::Config { editor: helix_view::editor::Config {
idle_timeout: IDLE_TIMEOUT, idle_timeout: IDLE_TIMEOUT,
default_line_ending: helix_view::editor::LineEndingConfig::LF, default_line_ending: DEFAULT_LINE_ENDING,
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()

Loading…
Cancel
Save