Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 76e170f

Browse files
authored
Merge pull request #604 from jonasbb/fix-599
Return CodeAction for any overlapping range, not just identical ranges (#599)
2 parents 8886e8f + 82eef18 commit 76e170f

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build = "build.rs"
1313
cargo = { git = "https://github.com/rust-lang/cargo" }
1414
env_logger = "0.4"
1515
jsonrpc-core = "7.0.1"
16-
languageserver-types = "0.14"
16+
languageserver-types = "0.16"
1717
lazy_static = "0.2"
1818
log = "0.3"
1919
racer = "2.0.12"

src/actions/requests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ impl CodeAction {
641641
if let Some(diagnostics) = ctx.previous_build_results.lock().unwrap().get(file_path) {
642642
let suggestions = diagnostics
643643
.iter()
644-
.filter(|&&(ref d, _)| d.range == params.range)
644+
.filter(|&&(ref d, _)| d.range.overlaps(&params.range))
645645
.flat_map(|&(_, ref ss)| ss.iter());
646646
for s in suggestions {
647647
let span = Location {

src/lsp_data.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,20 @@ pub fn completion_item_from_racer_match(m: racer::Match) -> CompletionItem {
236236
item
237237
}
238238

239+
/* ------ Extension methods for JSON-RPC protocol types ------ */
240+
241+
/// Provide additional methods for the remote `Range` type
242+
pub trait RangeExt {
243+
/// Do both Ranges overlap?
244+
fn overlaps(&self, other: &Self) -> bool;
245+
}
246+
247+
impl RangeExt for Range {
248+
fn overlaps(&self, other: &Self) -> bool {
249+
self.start <= other.end && other.start <= self.end
250+
}
251+
}
252+
239253
/* ----------------- JSON-RPC protocol types ----------------- */
240254

241255
/// Supported initilization options that can be passed in the `initialize`

0 commit comments

Comments
 (0)