Skip to content

Commit f572adb

Browse files
committed
ci: fix more windows test errors
1 parent f3bc407 commit f572adb

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

crates/lsp/src/providers/completion.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ mod tests {
482482
fn path_from_fixture(path: &str) -> Result<PathBuf> {
483483
let uri_str = if cfg!(windows) && path.starts_with('/') {
484484
// On Windows, convert Unix-style absolute paths to Windows-style
485-
format!("file://C:{path}")
485+
format!("file:///C:{path}")
486486
} else {
487487
format!("file://{path}")
488488
};
@@ -551,7 +551,13 @@ mod tests {
551551
.find_map(|document| document.cursor.map(|cursor| (document, cursor)))?;
552552

553553
let path = document.path.as_str();
554-
let uri = lsp_types::Uri::from_str(format!("file://{path}").as_str()).unwrap();
554+
let uri_str = if cfg!(windows) && path.starts_with('/') {
555+
// On Windows, convert Unix-style absolute paths to Windows-style
556+
format!("file:///C:{path}")
557+
} else {
558+
format!("file://{path}")
559+
};
560+
let uri = lsp_types::Uri::from_str(&uri_str).unwrap();
555561
let id = lsp_types::TextDocumentIdentifier::new(uri);
556562
Some(lsp_types::TextDocumentPositionParams::new(id, cursor))
557563
}
@@ -1116,10 +1122,18 @@ mod tests {
11161122
2023-10-01 open Assets:Test USD
11171123
"#;
11181124
let test_state = TestState::new(fixture).unwrap();
1125+
1126+
// Create a cross-platform compatible file URI
1127+
let uri_str = if cfg!(windows) {
1128+
// On Windows, convert Unix-style absolute paths to Windows-style
1129+
"file:///C:/main.beancount"
1130+
} else {
1131+
"file:///main.beancount"
1132+
};
1133+
let uri = lsp_types::Uri::from_str(uri_str).unwrap();
1134+
11191135
let cursor = lsp_types::TextDocumentPositionParams {
1120-
text_document: lsp_types::TextDocumentIdentifier {
1121-
uri: lsp_types::Uri::from_str("file:///main.beancount").unwrap(),
1122-
},
1136+
text_document: lsp_types::TextDocumentIdentifier { uri },
11231137
position: lsp_types::Position {
11241138
line: 0,
11251139
character: 26,

0 commit comments

Comments
 (0)