Skip to content

Commit a5d26a5

Browse files
Windows: Fix path handling for tree and file features
1 parent fd5dcf9 commit a5d26a5

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/server.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,23 @@ impl Server {
304304
path = &path[1..];
305305
}
306306
for p in path {
307-
path_buf.push(p);
307+
if cfg!(windows) {
308+
let mut chars = p.chars();
309+
match (chars.next(), chars.next(), chars.next()) {
310+
(Some(drive_letter), Some(colon), None)
311+
if drive_letter.is_ascii_alphabetic()
312+
&& colon == ':' => {
313+
let mut fixed_drive_prefix = String::new();
314+
fixed_drive_prefix.push(drive_letter);
315+
fixed_drive_prefix.push(colon);
316+
fixed_drive_prefix.push('\\');
317+
path_buf.push(&fixed_drive_prefix);
318+
},
319+
_ => path_buf.push(p),
320+
}
321+
} else {
322+
path_buf.push(p);
323+
}
308324
}
309325

310326
// FIXME should cache directory listings too

static/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class RustwApp extends React.Component {
3939
loadFileTreeData() {
4040
let self = this;
4141
utils.request(
42-
'tree/' + CONFIG.workspace_root,
42+
'tree/' + CONFIG.workspace_root.replace('\\', '/'),
4343
function(json) {
4444
if (json.Directory) {
4545
self.setState({ fileTreeData: json })

0 commit comments

Comments
 (0)