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

Commit ff90258

Browse files
committed
Fix test failures due to new text offsets
1 parent cd54b3a commit ff90258

File tree

70 files changed

+184
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+184
-182
lines changed

rls/src/actions/hover.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,51 +1282,51 @@ pub mod test {
12821282
let file = fixtures_dir().join("hover/src/test_extract_decl.rs");
12831283

12841284
let expected = "pub fn foo() -> Foo<u32>";
1285-
let row_start = Row::new_zero_indexed(10);
1285+
let row_start = Row::new_zero_indexed(0);
12861286
let actual = extract_decl(&vfs, &file, row_start).expect("function declaration").join("\n");
12871287
assert_eq!(expected, actual);
12881288

12891289
let expected = "pub struct Foo<T>";
1290-
let row_start = Row::new_zero_indexed(15);
1290+
let row_start = Row::new_zero_indexed(5);
12911291
let actual = extract_decl(&vfs, &file, row_start).expect("struct declaration").join("\n");
12921292
assert_eq!(expected, actual);
12931293

12941294
let expected = "pub enum Bar";
1295-
let row_start = Row::new_zero_indexed(20);
1295+
let row_start = Row::new_zero_indexed(10);
12961296
let actual = extract_decl(&vfs, &file, row_start).expect("enum declaration").join("\n");
12971297
assert_eq!(expected, actual);
12981298

12991299
let expected = "pub struct NewType(pub u32, f32)";
1300-
let row_start = Row::new_zero_indexed(25);
1300+
let row_start = Row::new_zero_indexed(15);
13011301
let actual = extract_decl(&vfs, &file, row_start).expect("tuple declaration").join("\n");
13021302
assert_eq!(expected, actual);
13031303

13041304
let expected = "pub fn new() -> NewType";
1305-
let row_start = Row::new_zero_indexed(28);
1305+
let row_start = Row::new_zero_indexed(18);
13061306
let actual =
13071307
extract_decl(&vfs, &file, row_start).expect("struct function declaration").join("\n");
13081308
assert_eq!(expected, actual);
13091309

13101310
let expected = "pub fn bar<T: Copy + Add>(&self, the_really_long_name_string: String, the_really_long_name_foo: Foo<T>) -> Vec<(String, Foo<T>)>";
1311-
let row_start = Row::new_zero_indexed(32);
1311+
let row_start = Row::new_zero_indexed(22);
13121312
let actual = extract_decl(&vfs, &file, row_start)
13131313
.expect("long struct method declaration with generics")
13141314
.join("\n");
13151315
assert_eq!(expected, actual);
13161316

13171317
let expected = "pub trait Baz<T> where T: Copy";
1318-
let row_start = Row::new_zero_indexed(37);
1318+
let row_start = Row::new_zero_indexed(27);
13191319
let actual = extract_decl(&vfs, &file, row_start).expect("enum declaration").join("\n");
13201320
assert_eq!(expected, actual);
13211321

13221322
let expected = "fn make_copy(&self) -> Self";
1323-
let row_start = Row::new_zero_indexed(38);
1323+
let row_start = Row::new_zero_indexed(28);
13241324
let actual =
13251325
extract_decl(&vfs, &file, row_start).expect("trait method declaration").join("\n");
13261326
assert_eq!(expected, actual);
13271327

13281328
let expected = "fn make_copy(&self) -> Self";
1329-
let row_start = Row::new_zero_indexed(42);
1329+
let row_start = Row::new_zero_indexed(32);
13301330
let actual =
13311331
extract_decl(&vfs, &file, row_start).expect("trait method implementation").join("\n");
13321332
assert_eq!(expected, actual);
@@ -1338,7 +1338,7 @@ pub mod test {
13381338
U: Clone
13391339
",
13401340
);
1341-
let row_start = Row::new_zero_indexed(47);
1341+
let row_start = Row::new_zero_indexed(37);
13421342
let actual =
13431343
extract_decl(&vfs, &file, row_start).expect("trait declaration multiline").join("\n");
13441344
assert_eq!(expected, actual);
@@ -1351,7 +1351,7 @@ pub mod test {
13511351
)
13521352
",
13531353
);
1354-
let row_start = Row::new_zero_indexed(53);
1354+
let row_start = Row::new_zero_indexed(43);
13551355
let actual = extract_decl(&vfs, &file, row_start)
13561356
.expect("function declaration multiline")
13571357
.join("\n");
@@ -1442,7 +1442,7 @@ pub mod test {
14421442
)
14431443
",
14441444
);
1445-
let row_start = Row::new_zero_indexed(21);
1445+
let row_start = Row::new_zero_indexed(1);
14461446
let actual = extract_decl(&vfs, &file, row_start)
14471447
.expect("the empty body should not be extracted")
14481448
.join("\n");
@@ -1501,7 +1501,7 @@ pub mod test {
15011501
fn test_extract_docs_comment_block() {
15021502
let vfs = Vfs::new();
15031503
let file = fixtures_dir().join("hover/src/test_extract_docs_comment_block.rs");
1504-
let row_start = Row::new_zero_indexed(21);
1504+
let row_start = Row::new_zero_indexed(11);
15051505
let actual = extract_docs(&vfs, &file, row_start)
15061506
.expect(&format!("failed to extract docs: {:?}", file))
15071507
.join("\n");
@@ -1525,7 +1525,7 @@ pub mod test {
15251525
fn test_extract_docs_empty_line_before_decl() {
15261526
let vfs = Vfs::new();
15271527
let file = fixtures_dir().join("hover/src/test_extract_docs_empty_line_before_decl.rs");
1528-
let row_start = Row::new_zero_indexed(18);
1528+
let row_start = Row::new_zero_indexed(8);
15291529
let actual = extract_docs(&vfs, &file, row_start)
15301530
.expect(&format!("failed to extract docs: {:?}", file))
15311531
.join("\n");
@@ -1569,7 +1569,7 @@ pub mod test {
15691569

15701570
assert_eq!(expected, actual);
15711571

1572-
let row_start = Row::new_zero_indexed(21);
1572+
let row_start = Row::new_zero_indexed(11);
15731573
let actual = extract_docs(&vfs, &file, row_start)
15741574
.expect(&format!("failed to extract docs: {:?}", file))
15751575
.join("\n");
@@ -1590,7 +1590,7 @@ pub mod test {
15901590
let vfs = Vfs::new();
15911591
let file = fixtures_dir().join("hover/src/test_extract_docs_attributes.rs");
15921592

1593-
let row_start = Row::new_zero_indexed(21);
1593+
let row_start = Row::new_zero_indexed(11);
15941594
let actual = extract_docs(&vfs, &file, row_start)
15951595
.expect(&format!("failed to extract docs: {:?}", file))
15961596
.join("\n");
@@ -1609,7 +1609,7 @@ pub mod test {
16091609

16101610
assert_eq!(expected, actual);
16111611

1612-
let row_start = Row::new_zero_indexed(32);
1612+
let row_start = Row::new_zero_indexed(22);
16131613
let actual = extract_docs(&vfs, &file, row_start)
16141614
.expect(&format!("failed to extract docs: {:?}", file))
16151615
.join("\n");

tests/client.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,8 @@ fn client_lens_run() {
10091009
}),
10101010
data: None,
10111011
range: Range {
1012-
start: Position { line: 14, character: 3 },
1013-
end: Position { line: 14, character: 11 },
1012+
start: Position { line: 4, character: 3 },
1013+
end: Position { line: 4, character: 11 },
10141014
},
10151015
};
10161016

@@ -1167,11 +1167,11 @@ fn client_deglob() {
11671167
text_document: TextDocumentIdentifier {
11681168
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
11691169
},
1170-
range: Range { start: Position::new(12, 0), end: Position::new(12, 0) },
1170+
range: Range { start: Position::new(2, 0), end: Position::new(2, 0) },
11711171
context: CodeActionContext { diagnostics: vec![], only: None },
11721172
},
11731173
)
1174-
.expect("No code actions returned for line 12");
1174+
.expect("No code actions returned for line 2");
11751175

11761176
// Right now we only support deglobbing via commands. Please update this
11771177
// test if we move to making text edits via CodeAction (which we should for
@@ -1193,7 +1193,7 @@ fn client_deglob() {
11931193
assert_eq!(
11941194
serde_json::from_value::<Location>(arguments[0]["location"].clone()).unwrap(),
11951195
Location {
1196-
range: Range { start: Position::new(12, 13), end: Position::new(12, 14) },
1196+
range: Range { start: Position::new(2, 13), end: Position::new(2, 14) },
11971197
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
11981198
}
11991199
);
@@ -1215,7 +1215,7 @@ fn client_deglob() {
12151215
assert_eq!(
12161216
edits,
12171217
vec![TextEdit {
1218-
range: Range { start: Position::new(12, 13), end: Position::new(12, 14) },
1218+
range: Range { start: Position::new(2, 13), end: Position::new(2, 14) },
12191219
new_text: "{Stdin, Stdout}".to_string(),
12201220
}]
12211221
);
@@ -1228,7 +1228,7 @@ fn client_deglob() {
12281228
text_document: TextDocumentIdentifier {
12291229
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
12301230
},
1231-
range: Range { start: Position::new(15, 0), end: Position::new(15, 0) },
1231+
range: Range { start: Position::new(5, 0), end: Position::new(5, 0) },
12321232
context: CodeActionContext { diagnostics: vec![], only: None },
12331233
},
12341234
)
@@ -1256,8 +1256,8 @@ fn client_deglob() {
12561256
serde_json::from_value::<Location>(arguments[i]["location"].clone()).unwrap(),
12571257
Location {
12581258
range: Range {
1259-
start: Position::new(15, expected[i].0),
1260-
end: Position::new(15, expected[i].1),
1259+
start: Position::new(5, expected[i].0),
1260+
end: Position::new(5, expected[i].1),
12611261
},
12621262
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
12631263
}
@@ -1283,7 +1283,7 @@ fn client_deglob() {
12831283
expected
12841284
.iter()
12851285
.map(|e| TextEdit {
1286-
range: Range { start: Position::new(15, e.0), end: Position::new(15, e.1) },
1286+
range: Range { start: Position::new(5, e.0), end: Position::new(5, e.1) },
12871287
new_text: e.2.to_string()
12881288
})
12891289
.collect::<Vec<_>>()
@@ -1816,9 +1816,9 @@ fn client_reformat() {
18161816
assert_eq!(result.unwrap()[0], TextEdit {
18171817
range: Range {
18181818
start: Position { line: 0, character: 0 },
1819-
end: Position { line: 12, character: 0 },
1819+
end: Position { line: 2, character: 0 },
18201820
},
1821-
new_text: "// Copyright 2017 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your\n// option. This file may not be copied, modified, or distributed\n// except according to those terms.\n\npub mod foo;\npub fn main() {\n let world = \"world\";\n println!(\"Hello, {}!\", world);\n}\n".to_string(),
1821+
new_text: "pub mod foo;\npub fn main() {\n let world = \"world\";\n println!(\"Hello, {}!\", world);\n}\n".to_string(),
18221822
});
18231823

18241824
rls.shutdown();
@@ -1843,8 +1843,8 @@ fn client_reformat_with_range() {
18431843
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
18441844
},
18451845
range: Range {
1846-
start: Position { line: 12, character: 0 },
1847-
end: Position { line: 13, character: 0 },
1846+
start: Position { line: 2, character: 0 },
1847+
end: Position { line: 3, character: 0 },
18481848
},
18491849
options: FormattingOptions {
18501850
tab_size: 4,
@@ -1855,7 +1855,7 @@ fn client_reformat_with_range() {
18551855
);
18561856

18571857
let newline = if cfg!(windows) { "\r\n" } else { "\n" };
1858-
let formatted = "// Copyright 2017 The Rust Project Developers. See the COPYRIGHT\n// file at the top-level directory of this distribution and at\n// http://rust-lang.org/COPYRIGHT.\n//\n// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your\n// option. This file may not be copied, modified, or distributed\n// except according to those terms.\n\npub fn main() {\n let world1 = \"world\";\n println!(\"Hello, {}!\", world1);\n let world2 = \"world\";\n println!(\"Hello, {}!\", world2);\n let world3 = \"world\";\n println!(\"Hello, {}!\", world3);\n}\n"
1858+
let formatted = "pub fn main() {\n let world1 = \"world\";\n println!(\"Hello, {}!\", world1);\n let world2 = \"world\";\n println!(\"Hello, {}!\", world2);\n let world3 = \"world\";\n println!(\"Hello, {}!\", world3);\n}\n"
18591859
.replace("\n", newline);
18601860

18611861
assert_eq!(result.unwrap()[0].new_text, formatted);
@@ -2031,10 +2031,10 @@ fn client_find_impls() {
20312031
1,
20322032
TextDocumentPositionParams {
20332033
text_document: TextDocumentIdentifier::new(uri.clone()),
2034-
position: Position { line: 12, character: 7 }, // "Bar"
2034+
position: Position { line: 3, character: 7 }, // "Bar"
20352035
},
20362036
);
2037-
let expected = [(18, 15, 18, 18), (19, 12, 19, 15)];
2037+
let expected = [(9, 15, 9, 18), (10, 12, 10, 15)];
20382038
let expected = expected.iter().map(|(a, b, c, d)| Location {
20392039
uri: uri.clone(),
20402040
range: Range {
@@ -2051,10 +2051,10 @@ fn client_find_impls() {
20512051
1,
20522052
TextDocumentPositionParams {
20532053
text_document: TextDocumentIdentifier::new(uri.clone()),
2054-
position: Position { line: 15, character: 6 }, // "Super"
2054+
position: Position { line: 6, character: 6 }, // "Super"
20552055
},
20562056
);
2057-
let expected = [(18, 15, 18, 18), (22, 15, 22, 18)];
2057+
let expected = [(9, 15, 9, 18), (13, 15, 13, 18)];
20582058
let expected = expected.iter().map(|(a, b, c, d)| Location {
20592059
uri: uri.clone(),
20602060
range: Range {

tests/fixtures/Cargo.lock

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

tests/fixtures/hover/save_data/test_tooltip_01.rs.0013_011.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0003_011.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 13,
4+
"line": 3,
55
"col": 11
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0015_007.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0005_007.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 15,
4+
"line": 5,
55
"col": 7
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0017_007.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0007_007.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 17,
4+
"line": 7,
55
"col": 7
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0021_013.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0011_013.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 21,
4+
"line": 11,
55
"col": 13
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0023_009.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0013_009.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 23,
4+
"line": 13,
55
"col": 9
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0023_016.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0013_016.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 23,
4+
"line": 13,
55
"col": 16
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0035_016.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0015_008.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"test": {
33
"file": "test_tooltip_01.rs",
4-
"line": 35,
5-
"col": 16
4+
"line": 15,
5+
"col": 8
66
},
77
"data": {
88
"Ok": [

0 commit comments

Comments
 (0)