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

Commit 1f237e5

Browse files
committed
Fix test failures due to new text offsets
1 parent 0e63bc4 commit 1f237e5

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
@@ -979,8 +979,8 @@ fn client_lens_run() {
979979
}),
980980
data: None,
981981
range: Range {
982-
start: Position { line: 14, character: 3 },
983-
end: Position { line: 14, character: 11 },
982+
start: Position { line: 4, character: 3 },
983+
end: Position { line: 4, character: 11 },
984984
},
985985
};
986986

@@ -1134,11 +1134,11 @@ fn client_deglob() {
11341134
text_document: TextDocumentIdentifier {
11351135
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
11361136
},
1137-
range: Range { start: Position::new(12, 0), end: Position::new(12, 0) },
1137+
range: Range { start: Position::new(2, 0), end: Position::new(2, 0) },
11381138
context: CodeActionContext { diagnostics: vec![], only: None },
11391139
},
11401140
)
1141-
.expect("No code actions returned for line 12");
1141+
.expect("No code actions returned for line 2");
11421142

11431143
// Right now we only support deglobbing via commands. Please update this
11441144
// test if we move to making text edits via CodeAction (which we should for
@@ -1160,7 +1160,7 @@ fn client_deglob() {
11601160
assert_eq!(
11611161
serde_json::from_value::<Location>(arguments[0]["location"].clone()).unwrap(),
11621162
Location {
1163-
range: Range { start: Position::new(12, 13), end: Position::new(12, 14) },
1163+
range: Range { start: Position::new(2, 13), end: Position::new(2, 14) },
11641164
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
11651165
}
11661166
);
@@ -1182,7 +1182,7 @@ fn client_deglob() {
11821182
assert_eq!(
11831183
edits,
11841184
vec![TextEdit {
1185-
range: Range { start: Position::new(12, 13), end: Position::new(12, 14) },
1185+
range: Range { start: Position::new(2, 13), end: Position::new(2, 14) },
11861186
new_text: "{Stdin, Stdout}".to_string(),
11871187
}]
11881188
);
@@ -1195,7 +1195,7 @@ fn client_deglob() {
11951195
text_document: TextDocumentIdentifier {
11961196
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
11971197
},
1198-
range: Range { start: Position::new(15, 0), end: Position::new(15, 0) },
1198+
range: Range { start: Position::new(5, 0), end: Position::new(5, 0) },
11991199
context: CodeActionContext { diagnostics: vec![], only: None },
12001200
},
12011201
)
@@ -1223,8 +1223,8 @@ fn client_deglob() {
12231223
serde_json::from_value::<Location>(arguments[i]["location"].clone()).unwrap(),
12241224
Location {
12251225
range: Range {
1226-
start: Position::new(15, expected[i].0),
1227-
end: Position::new(15, expected[i].1),
1226+
start: Position::new(5, expected[i].0),
1227+
end: Position::new(5, expected[i].1),
12281228
},
12291229
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
12301230
}
@@ -1250,7 +1250,7 @@ fn client_deglob() {
12501250
expected
12511251
.iter()
12521252
.map(|e| TextEdit {
1253-
range: Range { start: Position::new(15, e.0), end: Position::new(15, e.1) },
1253+
range: Range { start: Position::new(5, e.0), end: Position::new(5, e.1) },
12541254
new_text: e.2.to_string()
12551255
})
12561256
.collect::<Vec<_>>()
@@ -1756,9 +1756,9 @@ fn client_reformat() {
17561756
assert_eq!(result.unwrap()[0], TextEdit {
17571757
range: Range {
17581758
start: Position { line: 0, character: 0 },
1759-
end: Position { line: 12, character: 0 },
1759+
end: Position { line: 2, character: 0 },
17601760
},
1761-
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(),
1761+
new_text: "pub mod foo;\npub fn main() {\n let world = \"world\";\n println!(\"Hello, {}!\", world);\n}\n".to_string(),
17621762
});
17631763
}
17641764

@@ -1781,8 +1781,8 @@ fn client_reformat_with_range() {
17811781
uri: Url::from_file_path(p.root().join("src/main.rs")).unwrap(),
17821782
},
17831783
range: Range {
1784-
start: Position { line: 12, character: 0 },
1785-
end: Position { line: 13, character: 0 },
1784+
start: Position { line: 2, character: 0 },
1785+
end: Position { line: 3, character: 0 },
17861786
},
17871787
options: FormattingOptions {
17881788
tab_size: 4,
@@ -1793,7 +1793,7 @@ fn client_reformat_with_range() {
17931793
);
17941794

17951795
let newline = if cfg!(windows) { "\r\n" } else { "\n" };
1796-
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"
1796+
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"
17971797
.replace("\n", newline);
17981798

17991799
assert_eq!(result.unwrap()[0].new_text, formatted);
@@ -1957,10 +1957,10 @@ fn client_find_impls() {
19571957
1,
19581958
TextDocumentPositionParams {
19591959
text_document: TextDocumentIdentifier::new(uri.clone()),
1960-
position: Position { line: 12, character: 7 }, // "Bar"
1960+
position: Position { line: 3, character: 7 }, // "Bar"
19611961
},
19621962
);
1963-
let expected = [(18, 15, 18, 18), (19, 12, 19, 15)];
1963+
let expected = [(9, 15, 9, 18), (10, 12, 10, 15)];
19641964
let expected = expected.iter().map(|(a, b, c, d)| Location {
19651965
uri: uri.clone(),
19661966
range: Range {
@@ -1977,10 +1977,10 @@ fn client_find_impls() {
19771977
1,
19781978
TextDocumentPositionParams {
19791979
text_document: TextDocumentIdentifier::new(uri.clone()),
1980-
position: Position { line: 15, character: 6 }, // "Super"
1980+
position: Position { line: 6, character: 6 }, // "Super"
19811981
},
19821982
);
1983-
let expected = [(18, 15, 18, 18), (22, 15, 22, 18)];
1983+
let expected = [(9, 15, 9, 18), (13, 15, 13, 18)];
19841984
let expected = expected.iter().map(|(a, b, c, d)| Location {
19851985
uri: uri.clone(),
19861986
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": [

tests/fixtures/hover/save_data/test_tooltip_01.rs.0027_008.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0017_008.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": 27,
4+
"line": 17,
55
"col": 8
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0033_011.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0020_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": 33,
4+
"line": 20,
55
"col": 11
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_010.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0022_010.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": 32,
4+
"line": 22,
55
"col": 10
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0042_015.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0022_019.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": 42,
5-
"col": 15
4+
"line": 22,
5+
"col": 19
66
},
77
"data": {
88
"Ok": [

tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_026.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0022_026.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": 32,
4+
"line": 22,
55
"col": 26
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_035.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0022_035.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": 32,
4+
"line": 22,
55
"col": 35
66
},
77
"data": {

tests/fixtures/hover/save_data/test_tooltip_01.rs.0032_049.json renamed to tests/fixtures/hover/save_data/test_tooltip_01.rs.0022_049.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": 32,
4+
"line": 22,
55
"col": 49
66
},
77
"data": {

0 commit comments

Comments
 (0)