aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
authorAlex Zatelepin <[email protected]>2019-10-21 00:04:55 +0100
committerAlex Zatelepin <[email protected]>2019-10-21 19:35:42 +0100
commit9d5e9326266d6b064c6d0f5d78ba2fae4d78e8fb (patch)
tree8f68f7083cad16640f4f99b1ce6e77315e5bd5f4 /crates/ra_lsp_server/src/main_loop
parent6b9bd7bdd2712a7e85d6bfc70c231dbe36c2e585 (diff)
fixup folding ranges for "lineFoldingOnly" clients #2033
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 10e271376..af3cd04ea 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -18,7 +18,7 @@ use serde_json::to_value;
18 18
19use crate::{ 19use crate::{
20 cargo_target_spec::{runnable_args, CargoTargetSpec}, 20 cargo_target_spec::{runnable_args, CargoTargetSpec},
21 conv::{to_location, Conv, ConvWith, MapConvWith, TryConvWith, TryConvWithToVec}, 21 conv::{to_location, Conv, ConvWith, FoldConvCtx, MapConvWith, TryConvWith, TryConvWithToVec},
22 req::{self, Decoration, InlayHint, InlayHintsParams, InlayKind}, 22 req::{self, Decoration, InlayHint, InlayHintsParams, InlayKind},
23 world::WorldSnapshot, 23 world::WorldSnapshot,
24 LspError, Result, 24 LspError, Result,
@@ -383,8 +383,14 @@ pub fn handle_folding_range(
383) -> Result<Option<Vec<FoldingRange>>> { 383) -> Result<Option<Vec<FoldingRange>>> {
384 let file_id = params.text_document.try_conv_with(&world)?; 384 let file_id = params.text_document.try_conv_with(&world)?;
385 let folds = world.analysis().folding_ranges(file_id)?; 385 let folds = world.analysis().folding_ranges(file_id)?;
386 let text = world.analysis().file_text(file_id)?;
386 let line_index = world.analysis().file_line_index(file_id)?; 387 let line_index = world.analysis().file_line_index(file_id)?;
387 let res = Some(folds.into_iter().map_conv_with(&*line_index).collect()); 388 let ctx = FoldConvCtx {
389 text: &text,
390 line_index: &line_index,
391 line_folding_only: world.options.line_folding_only,
392 };
393 let res = Some(folds.into_iter().map_conv_with(&ctx).collect());
388 Ok(res) 394 Ok(res)
389} 395}
390 396