Skip to content

Commit

Permalink
Use the OS-specific newline when passing code to FSI
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed Nov 1, 2024
1 parent e438702 commit a0cf898
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions autoload/fsharp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ function! s:prompt(msg)
let &cmdheight = height
endfunction

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

" FSAC payload interfaces

Expand Down Expand Up @@ -661,7 +671,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 +694,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 a0cf898

Please sign in to comment.