Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
"command": "fsi.SendSelection",
"title": "FSI: Send Selection"
},
{
"command": "fsi.SendSelectionExtendedToWholeLine",
"title": "FSI: Send Selection Extended To Whole Line"
},
{
"command": "fsi.SendLastSelection",
"title": "FSI: Send Last Selection"
Expand Down Expand Up @@ -1015,6 +1019,12 @@
"mac": "alt\u002BEnter",
"when": "editorFocus \u0026\u0026 !findWidgetVisible \u0026\u0026 editorLangId == \u0027fsharp\u0027"
},
{
"command": "fsi.SendSelectionExtendedToWholeLine",
"key": "alt\u002Bshift\u002BEnter",
"mac": "alt\u002Bshift\u002BEnter",
"when": "editorFocus \u0026\u0026 !findWidgetVisible \u0026\u0026 editorLangId == \u0027fsharp\u0027"
},
{
"command": "fsharp.generateDoc",
"key": "alt\u002Bshift\u002Bj",
Expand Down Expand Up @@ -1195,6 +1205,10 @@
"command": "fsi.SendSelection",
"when": "editorLangId == \u0027fsharp\u0027"
},
{
"command": "fsi.SendSelectionExtendedToWholeLine",
"when": "editorLangId == \u0027fsharp\u0027"
},
{
"command": "fsi.SendLastSelection",
"when": "editorLangId == \u0027fsharp\u0027"
Expand Down Expand Up @@ -1818,4 +1832,4 @@
"url": "https://github.com/ionide/ionide-vscode-fsharp.git"
},
"version": "7.24.0"
}
}
31 changes: 31 additions & 0 deletions src/Components/Fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,34 @@ module Fsi =
do! send terminal text
}

let private sendSelectionExtendedToWholeLine () =
let editor = window.activeTextEditor.Value

promise {
if editor.selection.isEmpty then
do! sendLine ()
else
// Note: Handle terminal stuff only in this part of the if/else branch
// because sendLine will already handle it for the other branch

let! terminal = getTerminal ()

sendCd terminal (Some editor)

let range =
vscode.Range.Create(
editor.selection.anchor.line,
editor.selection.anchor.character,
editor.selection.active.line,
editor.selection.active.character
)

let fullRange = vscode.Range.Create(range.start.line, 0, range.``end``.line + 1., 0)
let text = editor.document.getText fullRange

do! send terminal text
}

let private sendLastSelection () =
promise {
match lastSelectionSent with
Expand Down Expand Up @@ -681,6 +709,9 @@ module Fsi =
commands.registerCommand ("fsi.SendSelection", sendSelection |> objfy2)
|> context.Subscribe

commands.registerCommand ("fsi.SendSelectionExtendedToWholeLine", sendSelectionExtendedToWholeLine |> objfy2)
|> context.Subscribe

commands.registerCommand ("fsi.SendLastSelection", sendLastSelection |> objfy2)
|> context.Subscribe

Expand Down