From 3b2f7356f95b2bf0b4fb1a37cc2a45f300dd08c4 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Fri, 4 Apr 2025 12:56:01 +0200 Subject: [PATCH 1/2] fix: log more --- crates/pgt_lsp/src/handlers/code_actions.rs | 2 ++ crates/pgt_lsp/src/handlers/completions.rs | 6 +---- crates/pgt_lsp/src/handlers/text_document.rs | 15 +++---------- .../src/workspace/server/change.rs | 22 +++++++++++++++++++ 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/crates/pgt_lsp/src/handlers/code_actions.rs b/crates/pgt_lsp/src/handlers/code_actions.rs index dd8b1f1e..0d124cfc 100644 --- a/crates/pgt_lsp/src/handlers/code_actions.rs +++ b/crates/pgt_lsp/src/handlers/code_actions.rs @@ -9,6 +9,7 @@ use pgt_workspace::features::code_actions::{ CodeActionKind, CodeActionsParams, CommandActionCategory, ExecuteStatementParams, }; +#[tracing::instrument(level = "debug", skip(session), err)] pub fn get_actions( session: &Session, params: lsp_types::CodeActionParams, @@ -71,6 +72,7 @@ pub fn command_id(command: &CommandActionCategory) -> String { } } +#[tracing::instrument(level = "debug", skip(session), err)] pub async fn execute_command( session: &Session, params: ExecuteCommandParams, diff --git a/crates/pgt_lsp/src/handlers/completions.rs b/crates/pgt_lsp/src/handlers/completions.rs index f18ae598..e9a18a6e 100644 --- a/crates/pgt_lsp/src/handlers/completions.rs +++ b/crates/pgt_lsp/src/handlers/completions.rs @@ -3,11 +3,7 @@ use anyhow::Result; use pgt_workspace::{WorkspaceError, features::completions::GetCompletionsParams}; use tower_lsp::lsp_types::{self, CompletionItem, CompletionItemLabelDetails}; -#[tracing::instrument(level = "debug", skip_all, fields( - url = params.text_document_position.text_document.uri.as_str(), - character = params.text_document_position.position.character, - line = params.text_document_position.position.line -), err)] +#[tracing::instrument(level = "debug", skip(session), err)] pub fn get_completions( session: &Session, params: lsp_types::CompletionParams, diff --git a/crates/pgt_lsp/src/handlers/text_document.rs b/crates/pgt_lsp/src/handlers/text_document.rs index d36b8a32..63250ef5 100644 --- a/crates/pgt_lsp/src/handlers/text_document.rs +++ b/crates/pgt_lsp/src/handlers/text_document.rs @@ -10,10 +10,7 @@ use tower_lsp::lsp_types; use tracing::error; /// Handler for `textDocument/didOpen` LSP notification -#[tracing::instrument(level = "info", skip_all, fields( - url = params.text_document.uri.as_str(), - version = params.text_document.version -), err)] +#[tracing::instrument(level = "debug", skip(session), err)] pub(crate) async fn did_open( session: &Session, params: lsp_types::DidOpenTextDocumentParams, @@ -41,11 +38,7 @@ pub(crate) async fn did_open( } // Handler for `textDocument/didChange` LSP notification -#[tracing::instrument(level = "debug", skip_all, fields( - uri = params.text_document.uri.as_str(), - version = params.text_document.version, - num_content_changes = params.content_changes.len() -), err)] +#[tracing::instrument(level = "debug", skip(session), err)] pub(crate) async fn did_change( session: &Session, params: lsp_types::DidChangeTextDocumentParams, @@ -97,9 +90,7 @@ pub(crate) async fn did_change( } /// Handler for `textDocument/didClose` LSP notification -#[tracing::instrument(level = "info", skip_all, fields( - url = params.text_document.uri.as_str(), -), err)] +#[tracing::instrument(level = "debug", skip(session), err)] pub(crate) async fn did_close( session: &Session, params: lsp_types::DidCloseTextDocumentParams, diff --git a/crates/pgt_workspace/src/workspace/server/change.rs b/crates/pgt_workspace/src/workspace/server/change.rs index 226a0ffd..4f4e5bf5 100644 --- a/crates/pgt_workspace/src/workspace/server/change.rs +++ b/crates/pgt_workspace/src/workspace/server/change.rs @@ -807,6 +807,28 @@ mod tests { assert_document_integrity(&d); } + #[test] + fn issue_303() { + let path = PgTPath::new("test.sql"); + let input = "create table \"test\""; + + let mut d = Document::new(PgTPath::new("test.sql"), input.to_string(), 0); + + assert_eq!(d.positions.len(), 1); + + let change = ChangeFileParams { + path: path.clone(), + version: 1, + changes: vec![ChangeParams { + text: "".to_string(), + range: Some(TextRange::new(18.into(), 19.into())), + }], + }; + + assert_eq!(d.content, "create table \"test"); + assert_document_integrity(&d); + } + #[test] fn across_statements() { let path = PgTPath::new("test.sql"); From 82531c12ace1e0d44753c2d50f87e4d7801463b3 Mon Sep 17 00:00:00 2001 From: psteinroe Date: Fri, 4 Apr 2025 12:58:56 +0200 Subject: [PATCH 2/2] fix: cleanup --- .../src/workspace/server/change.rs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/crates/pgt_workspace/src/workspace/server/change.rs b/crates/pgt_workspace/src/workspace/server/change.rs index 4f4e5bf5..226a0ffd 100644 --- a/crates/pgt_workspace/src/workspace/server/change.rs +++ b/crates/pgt_workspace/src/workspace/server/change.rs @@ -807,28 +807,6 @@ mod tests { assert_document_integrity(&d); } - #[test] - fn issue_303() { - let path = PgTPath::new("test.sql"); - let input = "create table \"test\""; - - let mut d = Document::new(PgTPath::new("test.sql"), input.to_string(), 0); - - assert_eq!(d.positions.len(), 1); - - let change = ChangeFileParams { - path: path.clone(), - version: 1, - changes: vec![ChangeParams { - text: "".to_string(), - range: Some(TextRange::new(18.into(), 19.into())), - }], - }; - - assert_eq!(d.content, "create table \"test"); - assert_document_integrity(&d); - } - #[test] fn across_statements() { let path = PgTPath::new("test.sql");