Skip to content

Commit

Permalink
Merge pull request #59 from SilasMarvin/silas-patch-eof-error
Browse files Browse the repository at this point in the history
Patched EOF error when chatting
  • Loading branch information
SilasMarvin authored Aug 11, 2024
2 parents 3a7c4ba + b180ab9 commit ef57dc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/lsp-ai/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lsp-ai"
version = "0.5.0"
version = "0.5.1"

description.workspace = true
repository.workspace = true
Expand Down
15 changes: 10 additions & 5 deletions crates/lsp-ai/src/transformer_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,12 @@ async fn do_code_action_resolve(
)))?;
let file_text = rx.await?;

let (messages_text, text_edit_line) = if chat.trigger == "" {
(file_text.as_str(), file_text.lines().count() + 1)
let (messages_text, text_edit_line, text_edit_char) = if chat.trigger == "" {
(
file_text.as_str(),
file_text.lines().count(),
file_text.lines().last().unwrap_or("").chars().count(),
)
} else {
let mut split = file_text.split(&chat.trigger);
let text_edit_line = split
Expand All @@ -435,7 +439,8 @@ async fn do_code_action_resolve(
.context("trigger not found when resolving chat code action")?;
(
messages_text,
text_edit_line + messages_text.lines().count() + 1,
text_edit_line + messages_text.lines().count(),
messages_text.lines().last().unwrap_or("").chars().count(),
)
};

Expand Down Expand Up @@ -515,8 +520,8 @@ async fn do_code_action_resolve(

let edit = TextEdit::new(
Range::new(
Position::new(text_edit_line as u32, 0),
Position::new(text_edit_line as u32, 0),
Position::new(text_edit_line as u32, text_edit_char as u32),
Position::new(text_edit_line as u32, text_edit_char as u32),
),
response.insert_text.clone(),
);
Expand Down

0 comments on commit ef57dc2

Please sign in to comment.