File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
crates/code_analysis/src/vfs Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -24,12 +24,7 @@ pub fn uri_to_file_path(uri: &Uri) -> Option<PathBuf> {
2424 let decoded_path = if cfg ! ( windows)
2525 {
2626 let mut windows_decoded_path = decoded_path. trim_start_matches ( '/' ) . replace ( '\\' , "/" ) ;
27- // 解码并处理驱动器字母
28- if windows_decoded_path. len ( ) >= 4 && & windows_decoded_path[ 1 ..4 ] . to_lowercase ( ) == "%3a" {
29- let drive = windows_decoded_path. chars ( ) . next ( ) ?. to_ascii_uppercase ( ) ;
30- let rest = & windows_decoded_path[ 4 ..] ;
31- windows_decoded_path = format ! ( "{}:{}" , drive, rest) ;
32- } else if windows_decoded_path. len ( ) >= 2 && windows_decoded_path. chars ( ) . nth ( 1 ) == Some ( ':' ) {
27+ if windows_decoded_path. len ( ) >= 2 && windows_decoded_path. chars ( ) . nth ( 1 ) == Some ( ':' ) {
3328 let drive = windows_decoded_path. chars ( ) . next ( ) ?. to_ascii_uppercase ( ) ;
3429 windows_decoded_path. replace_range ( ..2 , & format ! ( "{}:" , drive) ) ;
3530 }
Original file line number Diff line number Diff line change @@ -96,4 +96,15 @@ mod tests {
9696 assert_eq ! ( relative_path2, Path :: new( "test.lua" ) ) ;
9797 }
9898 }
99+
100+ #[ test]
101+ fn test_chinese_path ( ) {
102+ #[ cfg( windows) ]
103+ {
104+ let uri = Uri :: from_str ( "file:///c%3a/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9" ) . unwrap ( ) ;
105+ let path = uri_to_file_path ( & uri) . unwrap ( ) ;
106+ let result_path = Path :: new ( "c:/新建文件夹" ) ;
107+ assert_eq ! ( path, result_path) ;
108+ }
109+ }
99110}
You can’t perform that action at this time.
0 commit comments