@@ -8,6 +8,7 @@ use crate::shared::process_core::tokio_command;
88#[ cfg( target_os = "windows" ) ]
99use crate :: shared:: process_core:: { build_cmd_c_command, resolve_windows_executable} ;
1010use crate :: types:: WorkspaceEntry ;
11+ use crate :: utils:: normalize_windows_namespace_path;
1112
1213use super :: helpers:: resolve_workspace_root;
1314
@@ -133,13 +134,16 @@ fn build_launch_args(
133134) -> Vec < String > {
134135 let mut launch_args = args. to_vec ( ) ;
135136 if let Some ( ( line, column) ) = normalize_open_location ( line, column) {
136- let located_path = format_path_with_location ( path, line, column) ;
137137 match strategy {
138138 Some ( LineAwareLaunchStrategy :: GotoFlag ) => {
139+ let sanitized_path = normalize_windows_namespace_path ( path) ;
140+ let located_path = format_path_with_location ( & sanitized_path, line, column) ;
139141 launch_args. push ( "--goto" . to_string ( ) ) ;
140142 launch_args. push ( located_path) ;
141143 }
142144 Some ( LineAwareLaunchStrategy :: PathWithLineColumn ) => {
145+ let sanitized_path = normalize_windows_namespace_path ( path) ;
146+ let located_path = format_path_with_location ( & sanitized_path, line, column) ;
143147 launch_args. push ( located_path) ;
144148 }
145149 None => {
@@ -186,13 +190,8 @@ pub(crate) async fn open_workspace_in_core(
186190 if trimmed. is_empty ( ) {
187191 return Err ( "Missing app or command" . to_string ( ) ) ;
188192 }
189- let launch_args = build_launch_args (
190- & path,
191- & args,
192- line,
193- column,
194- command_launch_strategy ( trimmed) ,
195- ) ;
193+ let launch_args =
194+ build_launch_args ( & path, & args, line, column, command_launch_strategy ( trimmed) ) ;
196195
197196 #[ cfg( target_os = "windows" ) ]
198197 let mut cmd = {
@@ -380,6 +379,104 @@ mod tests {
380379 ) ;
381380 }
382381
382+ #[ test]
383+ fn builds_goto_args_with_windows_namespace_path_sanitized ( ) {
384+ let args = build_launch_args (
385+ r"\\?\I:\gpt-projects\json-composer\src\App.tsx" ,
386+ & [ "--reuse-window" . to_string ( ) ] ,
387+ Some ( 33 ) ,
388+ Some ( 7 ) ,
389+ Some ( LineAwareLaunchStrategy :: GotoFlag ) ,
390+ ) ;
391+
392+ assert_eq ! (
393+ args,
394+ vec![
395+ "--reuse-window" . to_string( ) ,
396+ "--goto" . to_string( ) ,
397+ r"I:\gpt-projects\json-composer\src\App.tsx:33:7" . to_string( ) ,
398+ ]
399+ ) ;
400+ }
401+
402+ #[ test]
403+ fn builds_goto_args_with_lowercase_unc_namespace_path_sanitized ( ) {
404+ let args = build_launch_args (
405+ r"\\?\unc\server\share\repo\src\App.tsx" ,
406+ & [ "--reuse-window" . to_string ( ) ] ,
407+ Some ( 12 ) ,
408+ Some ( 2 ) ,
409+ Some ( LineAwareLaunchStrategy :: GotoFlag ) ,
410+ ) ;
411+
412+ assert_eq ! (
413+ args,
414+ vec![
415+ "--reuse-window" . to_string( ) ,
416+ "--goto" . to_string( ) ,
417+ r"\\server\share\repo\src\App.tsx:12:2" . to_string( ) ,
418+ ]
419+ ) ;
420+ }
421+
422+ #[ test]
423+ fn preserves_namespace_path_for_unknown_targets ( ) {
424+ let args = build_launch_args (
425+ r"\\?\I:\very\long\workspace" ,
426+ & [ "--foreground" . to_string ( ) ] ,
427+ None ,
428+ None ,
429+ None ,
430+ ) ;
431+
432+ assert_eq ! (
433+ args,
434+ vec![
435+ "--foreground" . to_string( ) ,
436+ r"\\?\I:\very\long\workspace" . to_string( ) ,
437+ ]
438+ ) ;
439+ }
440+
441+ #[ test]
442+ fn preserves_namespace_path_for_line_aware_targets_without_location ( ) {
443+ let args = build_launch_args (
444+ r"\\?\I:\very\long\workspace" ,
445+ & [ "--reuse-window" . to_string ( ) ] ,
446+ None ,
447+ None ,
448+ Some ( LineAwareLaunchStrategy :: GotoFlag ) ,
449+ ) ;
450+
451+ assert_eq ! (
452+ args,
453+ vec![
454+ "--reuse-window" . to_string( ) ,
455+ r"\\?\I:\very\long\workspace" . to_string( ) ,
456+ ]
457+ ) ;
458+ }
459+
460+ #[ test]
461+ fn preserves_non_drive_namespace_path_for_line_aware_targets ( ) {
462+ let args = build_launch_args (
463+ r"\\?\Volume{01234567-89ab-cdef-0123-456789abcdef}\repo\src\App.tsx" ,
464+ & [ ] ,
465+ Some ( 5 ) ,
466+ None ,
467+ Some ( LineAwareLaunchStrategy :: GotoFlag ) ,
468+ ) ;
469+
470+ assert_eq ! (
471+ args,
472+ vec![
473+ "--goto" . to_string( ) ,
474+ r"\\?\Volume{01234567-89ab-cdef-0123-456789abcdef}\repo\src\App.tsx:5"
475+ . to_string( ) ,
476+ ]
477+ ) ;
478+ }
479+
383480 #[ test]
384481 fn builds_line_suffixed_path_for_zed_targets ( ) {
385482 let args = build_launch_args (
0 commit comments