Skip to content

Commit

Permalink
Fix #2064 -- Fsi: Send File Problem (#2065)
Browse files Browse the repository at this point in the history
* Fix Fsi Send File

* Fix Fsi Send File
  • Loading branch information
LH-and-FPGA authored Feb 19, 2025
1 parent ee363c5 commit 228531d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Components/Fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,15 @@ module Fsi =
let mutable lastCurrentFile: string option = None
let mutable lastCurrentLine: int option = None

let private sendCd (terminal: Terminal) (textEditor: TextEditor option) =
let private sendCd (terminal: Terminal) (textEditor: TextEditor option) (overrideLine: int option) =
let file, dir, line =
match textEditor with
| Some textEditor ->
let file = textEditor.document.fileName
let dir = node.path.dirname file
let line = int textEditor.selection.start.line + 1
let line = defaultArg overrideLine (int textEditor.selection.start.line + 1)
file, dir, line

| None ->
let dir = workspace.rootPath.Value
node.path.join (dir, "tmp.fsx"), dir, 1
Expand Down Expand Up @@ -471,7 +472,7 @@ module Fsi =
fsiTerminal <- Some terminal

// initially have to set up the terminal to be in the correct start directory
sendCd newTerminal window.activeTextEditor
sendCd newTerminal window.activeTextEditor None

return newTerminal
}
Expand Down Expand Up @@ -529,7 +530,7 @@ module Fsi =
let pos = editor.selection.start
let line = editor.document.lineAt pos

sendCd terminal (Some editor)
sendCd terminal (Some editor) None

do! send terminal line.text
do! moveCursorDownOneLine ()
Expand All @@ -547,7 +548,7 @@ module Fsi =

let! terminal = getTerminal ()

sendCd terminal (Some editor)
sendCd terminal (Some editor) None

let range =
vscode.Range.Create(
Expand All @@ -574,7 +575,7 @@ module Fsi =

let! terminal = getTerminal ()

sendCd terminal (Some editor)
sendCd terminal (Some editor) None

let range =
vscode.Range.Create(
Expand Down Expand Up @@ -612,7 +613,7 @@ module Fsi =
promise {
let! terminal = getTerminal ()

sendCd terminal (Some editor)
sendCd terminal (Some editor) (Some 1)
do! send terminal text
}

Expand Down

0 comments on commit 228531d

Please sign in to comment.