@@ -305,9 +305,16 @@ function logError(...args: any[]) {
305
305
logger . error ( logArgsToString ( args ) ) ;
306
306
}
307
307
308
+ function findPathSeparator ( filePath : string ) {
309
+ return filePath . includes ( '/' ) ? '/' : '\\' ;
310
+ }
311
+
308
312
function normalizePath ( filePath : string ) {
309
313
if ( process . platform === 'win32' ) {
314
+ const pathSeparator = findPathSeparator ( filePath ) ;
310
315
filePath = path . normalize ( filePath ) ;
316
+ // Normalize will replace everything with backslash on Windows.
317
+ filePath = filePath . replace ( / \\ / g, pathSeparator ) ;
311
318
return fixDriveCasingInWindows ( filePath ) ;
312
319
}
313
320
return filePath ;
@@ -754,13 +761,6 @@ class GoDebugSession extends LoggingDebugSession {
754
761
log ( 'InitializeResponse' ) ;
755
762
}
756
763
757
- protected findPathSeperator ( filePath : string ) {
758
- if ( / ^ ( \w : [ \\ / ] | \\ \\ ) / . test ( filePath ) ) {
759
- return '\\' ;
760
- }
761
- return filePath . includes ( '/' ) ? '/' : '\\' ;
762
- }
763
-
764
764
protected launchRequest ( response : DebugProtocol . LaunchResponse , args : LaunchRequestArguments ) : void {
765
765
if ( ! args . program ) {
766
766
this . sendErrorResponse (
@@ -835,10 +835,12 @@ class GoDebugSession extends LoggingDebugSession {
835
835
if ( this . delve . remotePath . length === 0 ) {
836
836
return this . convertClientPathToDebugger ( filePath ) ;
837
837
}
838
+ // The filePath may have a different path separator than the localPath
839
+ // So, update it to use the same separator as the remote path to ease
840
+ // in replacing the local path in it with remote path
841
+ filePath = filePath . replace ( / \/ | \\ / g, this . remotePathSeparator ) ;
838
842
return filePath
839
- . replace ( this . delve . program , this . delve . remotePath )
840
- . split ( this . localPathSeparator )
841
- . join ( this . remotePathSeparator ) ;
843
+ . replace ( this . delve . program . replace ( / \/ | \\ / g, this . remotePathSeparator ) , this . delve . remotePath ) ;
842
844
}
843
845
844
846
protected toLocalPath ( pathToConvert : string ) : string {
@@ -1392,8 +1394,8 @@ class GoDebugSession extends LoggingDebugSession {
1392
1394
}
1393
1395
1394
1396
if ( args . remotePath . length > 0 ) {
1395
- this . localPathSeparator = this . findPathSeperator ( localPath ) ;
1396
- this . remotePathSeparator = this . findPathSeperator ( args . remotePath ) ;
1397
+ this . localPathSeparator = findPathSeparator ( localPath ) ;
1398
+ this . remotePathSeparator = findPathSeparator ( args . remotePath ) ;
1397
1399
1398
1400
const llist = localPath . split ( / \/ | \\ / ) . reverse ( ) ;
1399
1401
const rlist = args . remotePath . split ( / \/ | \\ / ) . reverse ( ) ;
0 commit comments