<commit_before>let s:save_cpo = &cpoptions
set cpoptions&vim

function! OmniSharp#actions#project#Get(bufnr, Callback) abort
  if has_key(OmniSharp#GetHost(a:bufnr), 'project')
    call a:Callback()
    return
  endif
  let opts = {
  \ 'ResponseHandler': function('s:ProjectRH', [a:Callback, a:bufnr]),
  \ 'BufNum': a:bufnr,
  \ 'SendBuffer': 0
  \}
  call OmniSharp#stdio#Request('/project', opts)
endfunction

function! s:ProjectRH(Callback, bufnr, response) abort
  if !a:response.Success | return | endif
  let host = getbufvar(a:bufnr, 'OmniSharp_host')
  let host.project = a:response.Body
  call a:Callback()
endfunction

function! OmniSharp#actions#project#DebugProject(stopAtEntry, ...) abort
  if !OmniSharp#util#HasVimspector()
    echohl WarningMsg
    echomsg 'Vimspector required to debug project'
    echohl None
    return
  endif
  let bufnr = bufnr('%')
  function! DebugProjectCb(bufnr, stopAtEntry, args) abort
    let project = getbufvar(a:bufnr, 'OmniSharp_host').project
    " Make sure we're not running on a csx script
    if project.ScriptProject is v:null
      call vimspector#LaunchWithConfigurations({
      \  'launch': {
      \    'adapter': 'netcoredbg',
      \    'configuration': {
      \      'request': 'launch', 
      \      'program': project.MsBuildProject.TargetPath,
      \      'args': a:args,
      \      'stopAtEntry': a:stopAtEntry ? v:true : v:false
      \    }
      \  }
      \})
    else
      echohl WarningMsg
      echomsg 'DebugProject is not currently implemented for csx files'
      echohl None
    endif
  endfunction
  call OmniSharp#actions#project#Get(bufnr, function('DebugProjectCb', [bufnr, a:stopAtEntry, a:000]))
endfunction

function! OmniSharp#actions#project#CreateDebugConfig(stopAtEntry, ...) abort
  let bufnr = bufnr('%')
  function! CreateDebugConfigCb(bufnr, stopAtEntry, args) abort
    let host = getbufvar(a:bufnr, 'OmniSharp_host')
    let contents = [
          \' {',
          \'   "configurations": {',
          \'     "attach": {',
          \'       "adapter": "netcoredbg",',
          \'       "configuration": {',
          \'         "request": "attach",',
          \'         "processId": "${pid}"',
          \'       }',
          \'     },',
          \'     "launch": {',
          \'       "adapter": "netcoredbg",',
          \'       "configuration": {',
          \'         "request": "launch",',
          \'         "program": "'.host.project.MsBuildProject.TargetPath.'",',
          \'         "args": ' . json_encode(a:args) . ',',<commit_msg>fix      (debugger): set cwd for appsettings file acces, and fix windows separators in path<commit_after>let s:save_cpo = &cpoptions
set cpoptions&vim

function! OmniSharp#actions#project#Get(bufnr, Callback) abort
  if has_key(OmniSharp#GetHost(a:bufnr), 'project')
    call a:Callback()
    return
  endif
  let opts = {
  \ 'ResponseHandler': function('s:ProjectRH', [a:Callback, a:bufnr]),
  \ 'BufNum': a:bufnr,
  \ 'SendBuffer': 0
  \}
  call OmniSharp#stdio#Request('/project', opts)
endfunction

function! s:ProjectRH(Callback, bufnr, response) abort
  if !a:response.Success | return | endif
  let host = getbufvar(a:bufnr, 'OmniSharp_host')
  let host.project = a:response.Body
  call a:Callback()
endfunction

function! OmniSharp#actions#project#DebugProject(stopAtEntry, ...) abort
  if !OmniSharp#util#HasVimspector()
    echohl WarningMsg
    echomsg 'Vimspector required to debug project'
    echohl None
    return
  endif
  let bufnr = bufnr('%')
  function! DebugProjectCb(bufnr, stopAtEntry, args) abort
    let project = getbufvar(a:bufnr, 'OmniSharp_host').project
    " Make sure we're not running on a csx script
    if project.ScriptProject is v:null
      let targetProgramFilename =    fnamemodify(project.MsBuildProject.TargetPath, ':t')
      let folderWithAppConfigFiles = fnamemodify(project.MsBuildProject.TargetPath, ':h:p')
      if has('win32')
        let folderWithAppConfigFiles = substitute(folderWithAppConfigFiles, '\', '/', 'g')
      endif
      call vimspector#LaunchWithConfigurations({
      \  'launch': {
      \    'adapter': 'netcoredbg',
      \    'configuration': {
      \      'request': 'launch',
      \      'cwd': folderWithAppConfigFiles,
      \      'program': targetProgramFilename,
      \      'args': a:args,
      \      'stopAtEntry': a:stopAtEntry ? v:true : v:false
      \    }
      \  }
      \})
    else
      echohl WarningMsg
      echomsg 'DebugProject is not currently implemented for csx files'
      echohl None
    endif
  endfunction
  call OmniSharp#actions#project#Get(bufnr, function('DebugProjectCb', [bufnr, a:stopAtEntry, a:000]))
endfunction

function! OmniSharp#actions#project#CreateDebugConfig(stopAtEntry, ...) abort
  let bufnr = bufnr('%')
  function! CreateDebugConfigCb(bufnr, stopAtEntry, args) abort
    let host = getbufvar(a:bufnr, 'OmniSharp_host')
    let targetProgramFilename =    fnamemodify(host.project.MsBuildProject.TargetPath, ':t')
    let folderWithAppConfigFiles = fnamemodify(host.project.MsBuildProject.TargetPath, ':h:p')
    if has('win32')
      let folderWithAppConfigFiles = substitute(folderWithAppConfigFiles, '\', '/', 'g')
    endif
    let contents = [
          \' {',
          \'   "configurations": {',
          \'     "attach": {',
          \'       "adapter": "netcoredbg",',
          \'       "configuration": {',
          \'         "request": "attach",',
          \'         "processId": "${pid}"',
          \'       }',
          \'     },',
          \'     "launch": {',
          \'       "adapter": "netcoredbg",',
          \'       "configuration": {',
          \'         "request": "launch",',
          \'         "cwd": "' . folderWithAppConfigFiles . '",',
          \'         "program": "' . targetProgramFilename . '",',
          \'         "args": ' . json_encode(a:args) . ',',
{'fraction_non_alphanumeric': 0.14280868385345996, 'fraction_numerical': 0.0020352781546811396, 'mean_word_length': 2.6356350184956843, 'pattern_counts': {'":': 25, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4610968', 'n_tokens_mistral': 1963, 'n_tokens_neox': 1854, 'n_words': 379}