Skip to content

Commit 36f0fe4

Browse files
authored
Disable formatting in LSP due to incorrect behavior (#1793)
We dont apply unsaved changes to the files so stuff gets reverted to how it was before saving.
1 parent bf830dd commit 36f0fe4

1 file changed

Lines changed: 52 additions & 51 deletions

File tree

  • engine/language_server/src/server/api/requests

engine/language_server/src/server/api/requests/format.rs

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,56 +20,57 @@ impl SyncRequestHandler for DocumentFormatting {
2020
_requester: &mut Requester,
2121
params: DocumentFormattingParams,
2222
) -> Result<Option<Vec<lsp_types::TextEdit>>> {
23-
let url = &params.text_document.uri;
24-
let path = url
25-
.to_file_path()
26-
.internal_error_msg("Could not convert URL to path")?;
27-
session
28-
.ensure_project_db_for_baml_file(url)
29-
.internal_error()?;
30-
let project = session
31-
.project_db_for_path_mut(path)
32-
.expect("Ensured that a project db exists");
33-
let document_key = DocumentKey::from_url(
34-
&PathBuf::from(project.lock().unwrap().baml_project.root_dir_name.clone()),
35-
&url,
36-
)
37-
.internal_error()?;
38-
let doc_contents = match project
39-
.lock()
40-
.unwrap()
41-
.baml_project
42-
.files
43-
.get(&document_key)
44-
{
45-
None => {
46-
tracing::warn!("Failed to find doc {:?}", url);
47-
Err(anyhow::anyhow!(
48-
"File {} was not present in the project",
49-
url
50-
))
51-
}
52-
Some(text_document) => Ok(text_document.contents.clone()),
53-
}
54-
.internal_error()?;
55-
format_schema(
56-
&doc_contents,
57-
FormatOptions {
58-
indent_width: 2,
59-
fail_on_unhandled_rule: false,
60-
},
61-
)
62-
.map(|new_contents| {
63-
Ok(Some(vec![TextEdit {
64-
range: full_document_range(&doc_contents),
65-
new_text: new_contents,
66-
}]))
67-
})
68-
.unwrap_or_else(|e| {
69-
notifier
70-
.notify_baml_error(e.to_string().as_str())
71-
.internal_error()?;
72-
Ok(None)
73-
})
23+
// let url = &params.text_document.uri;
24+
// let path = url
25+
// .to_file_path()
26+
// .internal_error_msg("Could not convert URL to path")?;
27+
// session
28+
// .ensure_project_db_for_baml_file(url)
29+
// .internal_error()?;
30+
// let project = session
31+
// .project_db_for_path_mut(path)
32+
// .expect("Ensured that a project db exists");
33+
// let document_key = DocumentKey::from_url(
34+
// &PathBuf::from(project.lock().unwrap().baml_project.root_dir_name.clone()),
35+
// &url,
36+
// )
37+
// .internal_error()?;
38+
// let doc_contents = match project
39+
// .lock()
40+
// .unwrap()
41+
// .baml_project
42+
// .files
43+
// .get(&document_key)
44+
// {
45+
// None => {
46+
// tracing::warn!("Failed to find doc {:?}", url);
47+
// Err(anyhow::anyhow!(
48+
// "File {} was not present in the project",
49+
// url
50+
// ))
51+
// }
52+
// Some(text_document) => Ok(text_document.contents.clone()),
53+
// }
54+
// .internal_error()?;
55+
// format_schema(
56+
// &doc_contents,
57+
// FormatOptions {
58+
// indent_width: 2,
59+
// fail_on_unhandled_rule: false,
60+
// },
61+
// )
62+
// .map(|new_contents| {
63+
// Ok(Some(vec![TextEdit {
64+
// range: full_document_range(&doc_contents),
65+
// new_text: new_contents,
66+
// }]))
67+
// })
68+
// .unwrap_or_else(|e| {
69+
// notifier
70+
// .notify_baml_error(e.to_string().as_str())
71+
// .internal_error()?;
72+
// Ok(None)
73+
// })
74+
Ok(None)
7475
}
7576
}

0 commit comments

Comments
 (0)