diff --git a/release/package.json b/release/package.json index 02d7cbdf..64df5500 100644 --- a/release/package.json +++ b/release/package.json @@ -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" @@ -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", @@ -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" @@ -1818,4 +1832,4 @@ "url": "https://github.com/ionide/ionide-vscode-fsharp.git" }, "version": "7.24.0" -} \ No newline at end of file +} diff --git a/src/Components/Fsi.fs b/src/Components/Fsi.fs index e963f7b6..0cda51bc 100644 --- a/src/Components/Fsi.fs +++ b/src/Components/Fsi.fs @@ -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 @@ -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