diff options
Diffstat (limited to 'crates/server/src/main_loop/handlers.rs')
-rw-r--r-- | crates/server/src/main_loop/handlers.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/server/src/main_loop/handlers.rs b/crates/server/src/main_loop/handlers.rs index ec5421f06..ca5cd5ab1 100644 --- a/crates/server/src/main_loop/handlers.rs +++ b/crates/server/src/main_loop/handlers.rs | |||
@@ -314,6 +314,25 @@ pub fn handle_completion( | |||
314 | Ok(Some(req::CompletionResponse::Array(items))) | 314 | Ok(Some(req::CompletionResponse::Array(items))) |
315 | } | 315 | } |
316 | 316 | ||
317 | pub fn handle_on_type_formatting( | ||
318 | world: ServerWorld, | ||
319 | params: req::DocumentOnTypeFormattingParams, | ||
320 | ) -> Result<Option<Vec<TextEdit>>> { | ||
321 | if params.ch != "=" { | ||
322 | return Ok(None); | ||
323 | } | ||
324 | |||
325 | let file_id = params.text_document.try_conv_with(&world)?; | ||
326 | let line_index = world.analysis().file_line_index(file_id)?; | ||
327 | let offset = params.position.conv_with(&line_index); | ||
328 | let file = world.analysis().file_syntax(file_id)?; | ||
329 | let action = match libeditor::on_eq_typed(&file, offset) { | ||
330 | None => return Ok(None), | ||
331 | Some(action) => action, | ||
332 | }; | ||
333 | Ok(Some(action.edit.conv_with(&line_index))) | ||
334 | } | ||
335 | |||
317 | pub fn handle_execute_command( | 336 | pub fn handle_execute_command( |
318 | world: ServerWorld, | 337 | world: ServerWorld, |
319 | mut params: req::ExecuteCommandParams, | 338 | mut params: req::ExecuteCommandParams, |