@@ -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
@@ -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: substituteRemotePath ( m [1 ])
361
361
let linenr = m [2 ]
362
362
let oldfile = fnamemodify (expand (' %' ), ' :p:gs!\\!/!' )
363
363
if oldfile != filename
@@ -1418,7 +1418,7 @@ endfunction
1418
1418
1419
1419
" Toggle breakpoint. Returns 0 on success and 1 on failure.
1420
1420
function ! go#debug#Breakpoint (... ) abort
1421
- let l: filename = fnamemodify (expand (' %' ), ' :p:gs!\\!/!' )
1421
+ let l: filename = s: substituteLocalPath ( fnamemodify (expand (' %' ), ' :p:gs!\\!/!' ) )
1422
1422
let l: linenr = line (' .' )
1423
1423
1424
1424
" Get line number from argument.
@@ -1737,6 +1737,24 @@ 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 l: from [0 : len (a: path )-1 ] != l: from
1751
+ continue
1752
+ endif
1753
+ return printf (' %s%s' , l: to , a: path [len (l: from )])
1754
+ endfor
1755
+ return a: path
1756
+ endfunction
1757
+
1740
1758
" restore Vi compatibility settings
1741
1759
let &cpo = s: cpo_save
1742
1760
unlet s: cpo_save
0 commit comments