Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2064 -- Fsi: Send File Problem #2065

Merged
merged 2 commits into from
Feb 19, 2025
Merged
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
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