Skip to content

Commit

Permalink
Merge pull request #90 from ionide/fix/call-fsi-with-os-newline
Browse files Browse the repository at this point in the history
Use the OS-specific newline when passing code to FSI
  • Loading branch information
cannorin authored Nov 3, 2024
2 parents e438702 + a9eda69 commit c7e8973
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions autoload/fsharp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ function! s:prompt(msg)
let &cmdheight = height
endfunction

function! s:get_newline()
if has('win32') || &fileformat == 'dos'
return "\r\n"
else
return "\n"
endif
endfunction
let s:newline = s:get_newline()

" FSAC payload interfaces

Expand Down Expand Up @@ -661,7 +669,7 @@ function! fsharp#sendFsi(text)
if fsharp#openFsi(!g:fsharp#fsi_focus_on_send) > 0
" Neovim
if has('nvim')
call chansend(s:fsi_job, a:text . "\n" . ";;". "\n")
call chansend(s:fsi_job, a:text . s:newline . ";;". s:newline)
" Vim 8
else
call term_sendkeys(s:fsi_buffer, a:text . "\<cr>" . ";;" . "\<cr>")
Expand All @@ -684,13 +692,13 @@ function! s:get_visual_selection()
endfunction

function! s:get_complete_buffer()
return join(getline(1, '$'), "\n")
return join(getline(1, '$'), s:newline)
endfunction

function! fsharp#sendSelectionToFsi() range
let lines = s:get_visual_selection()
exec 'normal' len(lines) . 'j'
let text = join(lines, "\n")
let text = join(lines, s:newline)
return fsharp#sendFsi(text)
endfunction

Expand Down

0 comments on commit c7e8973

Please sign in to comment.