Skip to content

Commit 9365732

Browse files
author
Minh-Tam TRAN
committed
fix (debugger): set cwd for appsettings file acces, and fix windows separators in path
1 parent b25f07c commit 9365732

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

autoload/OmniSharp/actions/project.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ function! OmniSharp#actions#project#DebugProject(stopAtEntry, ...) abort
3333
let project = getbufvar(a:bufnr, 'OmniSharp_host').project
3434
" Make sure we're not running on a csx script
3535
if project.ScriptProject is v:null
36+
let targetProgramFilename = fnamemodify(project.MsBuildProject.TargetPath, ':t')
37+
let folderWithAppConfigFiles = fnamemodify(project.MsBuildProject.TargetPath, ':h:p')
38+
if has('win32')
39+
let folderWithAppConfigFiles = substitute(folderWithAppConfigFiles, '\', '/', 'g')
40+
endif
3641
call vimspector#LaunchWithConfigurations({
3742
\ 'launch': {
3843
\ 'adapter': 'netcoredbg',
3944
\ 'configuration': {
40-
\ 'request': 'launch',
41-
\ 'program': project.MsBuildProject.TargetPath,
45+
\ 'request': 'launch',
46+
\ 'cwd': folderWithAppConfigFiles,
47+
\ 'program': targetProgramFilename,
4248
\ 'args': a:args,
4349
\ 'stopAtEntry': a:stopAtEntry ? v:true : v:false
4450
\ }
@@ -57,6 +63,11 @@ function! OmniSharp#actions#project#CreateDebugConfig(stopAtEntry, ...) abort
5763
let bufnr = bufnr('%')
5864
function! CreateDebugConfigCb(bufnr, stopAtEntry, args) abort
5965
let host = getbufvar(a:bufnr, 'OmniSharp_host')
66+
let targetProgramFilename = fnamemodify(host.project.MsBuildProject.TargetPath, ':t')
67+
let folderWithAppConfigFiles = fnamemodify(host.project.MsBuildProject.TargetPath, ':h:p')
68+
if has('win32')
69+
let folderWithAppConfigFiles = substitute(folderWithAppConfigFiles, '\', '/', 'g')
70+
endif
6071
let contents = [
6172
\' {',
6273
\' "configurations": {',
@@ -71,7 +82,8 @@ function! OmniSharp#actions#project#CreateDebugConfig(stopAtEntry, ...) abort
7182
\' "adapter": "netcoredbg",',
7283
\' "configuration": {',
7384
\' "request": "launch",',
74-
\' "program": "'.host.project.MsBuildProject.TargetPath.'",',
85+
\' "cwd": "' . folderWithAppConfigFiles . '",',
86+
\' "program": "' . targetProgramFilename . '",',
7587
\' "args": ' . json_encode(a:args) . ',',
7688
\' "stopAtEntry": ' . (a:stopAtEntry ? 'true' : 'false'),
7789
\' }',

0 commit comments

Comments
 (0)