File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
crates/emmylua_ls/src/handlers
document_range_formatting Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,13 @@ pub async fn on_formatting_handler(
1919 let client_id = config_manager. client_config . client_id ;
2020
2121 let file_id = analysis. get_file_id ( & uri) ?;
22- let semantic_model = analysis. compilation . get_semantic_model ( file_id) ?;
23- let document = semantic_model. get_document ( ) ;
22+ let syntax_tree = analysis. compilation . get_db ( ) . get_vfs ( ) . get_syntax_tree ( & file_id) ?;
23+
24+ if !syntax_tree. get_errors ( ) . is_empty ( ) {
25+ return None ;
26+ }
27+
28+ let document = analysis. compilation . get_db ( ) . get_vfs ( ) . get_document ( & file_id) ?;
2429 let text = document. get_text ( ) ;
2530 let file_path = document. get_file_path ( ) ;
2631 let normalized_path = file_path. to_string_lossy ( ) . to_string ( ) . replace ( "\\ " , "/" ) ;
Original file line number Diff line number Diff line change @@ -20,8 +20,21 @@ pub async fn on_range_formatting_handler(
2020 let config_manager = context. workspace_manager . read ( ) . await ;
2121 let client_id = config_manager. client_config . client_id ;
2222 let file_id = analysis. get_file_id ( & uri) ?;
23- let semantic_model = analysis. compilation . get_semantic_model ( file_id) ?;
24- let document = semantic_model. get_document ( ) ;
23+ let syntax_tree = analysis
24+ . compilation
25+ . get_db ( )
26+ . get_vfs ( )
27+ . get_syntax_tree ( & file_id) ?;
28+
29+ if !syntax_tree. get_errors ( ) . is_empty ( ) {
30+ return None ;
31+ }
32+
33+ let document = analysis
34+ . compilation
35+ . get_db ( )
36+ . get_vfs ( )
37+ . get_document ( & file_id) ?;
2538 let text = document. get_text ( ) ;
2639 let file_path = document. get_file_path ( ) ;
2740 let normalized_path = file_path. to_string_lossy ( ) . to_string ( ) . replace ( "\\ " , "/" ) ;
Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ pub fn server_capabilities(client_capabilities: &ClientCapabilities) -> ServerCa
121121 & mut server_capabilities,
122122 client_capabilities,
123123 ) ;
124+ // register::<document_type_formatting::DocumentTypeFormatting>(
125+ // &mut server_capabilities,
126+ // client_capabilities,
127+ // );
124128
125129 server_capabilities
126130}
You can’t perform that action at this time.
0 commit comments