@@ -158,7 +158,7 @@ function! s:update_breakpoint(res) abort
158
158
endif
159
159
160
160
exe bufs[0 ][0 ] ' wincmd w'
161
- let filename = state .currentThread.file
161
+ let filename = s: substituteRemotePath ( state .currentThread.file )
162
162
let linenr = state .currentThread.line
163
163
let oldfile = fnamemodify (expand (' %' ), ' :p:gs!\\!/!' )
164
164
if oldfile != filename
@@ -202,7 +202,7 @@ function! s:show_stacktrace(check_errors, res) abort
202
202
if loc .file is # ' ?' || ! has_key (loc , ' function' )
203
203
continue
204
204
endif
205
- call setline (i + 1 , printf (' %s - %s:%d' , loc .function .name, fnamemodify (loc .file , ' :p' ), loc .line ))
205
+ call setline (i + 1 , printf (' %s - %s:%d' , loc .function .name, s: substituteRemotePath ( fnamemodify (loc .file , ' :p' ) ), loc .line ))
206
206
endfor
207
207
finally
208
208
setlocal nomodifiable
@@ -357,7 +357,7 @@ function! s:goto_file() abort
357
357
return
358
358
endif
359
359
exe bufs[0 ][0 ] ' wincmd w'
360
- let filename = m [1 ]
360
+ let filename = s: substituteLocalPath ( m [1 ])
361
361
let linenr = m [2 ]
362
362
let oldfile = fnamemodify (expand (' %' ), ' :p:gs!\\!/!' )
363
363
if oldfile != filename
@@ -1140,9 +1140,9 @@ function! s:show_goroutines(currentGoroutineID, res) abort
1140
1140
" lines is modified, then make sure that go#debug#Goroutine is also
1141
1141
" changed if needed.
1142
1142
if l: goroutine .id == a: currentGoroutineID
1143
- let l: g = printf (" * Goroutine %s - %s: %s:%s %s (thread: %s)" , l: goroutine .id, l: goroutineType , l: loc .file , l: loc .line , l: loc .function .name, l: goroutine .threadID)
1143
+ let l: g = printf (" * Goroutine %s - %s: %s:%s %s (thread: %s)" , l: goroutine .id, l: goroutineType , s: substituteRemotePath ( l: loc .file ) , l: loc .line , l: loc .function .name, l: goroutine .threadID)
1144
1144
else
1145
- let l: g = printf (" Goroutine %s - %s: %s:%s %s (thread: %s)" , l: goroutine .id, l: goroutineType , l: loc .file , l: loc .line , l: loc .function .name, l: goroutine .threadID)
1145
+ let l: g = printf (" Goroutine %s - %s: %s:%s %s (thread: %s)" , l: goroutine .id, l: goroutineType , s: substituteRemotePath ( l: loc .file ) , l: loc .line , l: loc .function .name, l: goroutine .threadID)
1146
1146
endif
1147
1147
let v += [l: g ]
1148
1148
endfor
@@ -1454,10 +1454,10 @@ function! go#debug#Breakpoint(...) abort
1454
1454
else " Add breakpoint
1455
1455
if s: isReady ()
1456
1456
let l: promise = go#promise#New (function (' s:rpc_response' ), 20000 , {})
1457
- call s: call_jsonrpc (l: promise .wrapper, ' RPCServer.CreateBreakpoint' , {' Breakpoint' : {' file' : l: filename , ' line' : l: linenr }})
1457
+ call s: call_jsonrpc (l: promise .wrapper, ' RPCServer.CreateBreakpoint' , {' Breakpoint' : {' file' : s: substituteLocalPath ( l: filename) , ' line' : l: linenr }})
1458
1458
let l: res = l: promise .await ()
1459
1459
let l: bt = l: res .result.Breakpoint
1460
- call s: sign_place (l: bt .id, l: bt .file , l: bt .line )
1460
+ call s: sign_place (l: bt .id, s: substituteRemotePath ( l: bt .file ) , l: bt .line )
1461
1461
else
1462
1462
let l: id = len (s: list_breakpoints ()) + 1
1463
1463
call s: sign_place (l: id , l: filename , l: linenr )
@@ -1617,7 +1617,7 @@ function! s:handle_staleness_check_response(filename, check_errors, res) abort
1617
1617
endfunction
1618
1618
1619
1619
function ! s: warn_stale (filename) abort
1620
- call go#util#EchoWarning (printf (' file locations may be incorrect, because %s has changed since debugging started' , a: filename ))
1620
+ call go#util#EchoWarning (printf (' file locations may be incorrect, because %s has changed since debugging started' , a: filename ))
1621
1621
endfunction
1622
1622
1623
1623
@@ -1737,6 +1737,29 @@ function! s:restore_mapping(maparg)
1737
1737
return
1738
1738
endfunction
1739
1739
1740
+ function ! s: substituteRemotePath (path ) abort
1741
+ return s: substitutePath (a: path , go#config#DebugSubstitutePaths ())
1742
+ endfunction
1743
+
1744
+ function ! s: substituteLocalPath (path ) abort
1745
+ return s: substitutePath (a: path , map (deepcopy (go#config#DebugSubstitutePaths ()), ' [v:val[1], v:val[0]]' ))
1746
+ endfunction
1747
+
1748
+ function ! s: substitutePath (path , substitutions) abort
1749
+ for [l: from , l: to ] in a: substitutions
1750
+ if len (a: path ) < len (l: from )
1751
+ continue
1752
+ endif
1753
+ if a: path [0 : len (l: from )-1 ] != l: from
1754
+ continue
1755
+ endif
1756
+
1757
+ return printf (' %s%s' , l: to , a: path [len (l: from ):-1 ])
1758
+ endfor
1759
+
1760
+ return a: path
1761
+ endfunction
1762
+
1740
1763
" restore Vi compatibility settings
1741
1764
let &cpo = s: cpo_save
1742
1765
unlet s: cpo_save
0 commit comments