Skip to content

Commit

Permalink
fix and improve (#1952)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tangent-90 committed Oct 21, 2023
1 parent bc9a03d commit 88e9f52
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
7 changes: 6 additions & 1 deletion release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@
"description": "Includes external (from unopened modules and namespaces) symbols in autocomplete",
"type": "boolean"
},
"FSharp.fullNameExternalAutocomplete": {
"default": false,
"description": "When selecting an external symbols in autocomplete, insert the full name to the editor rather than open its module/namespace. Also allow filtering suggestions by typing its full name. \n\n Requires `FSharp.externalAutocomplete` enabled.",
"type": "boolean"
},
"FSharp.fsac.attachDebugger": {
"default": false,
"description": "Appends the \u0027--attachdebugger\u0027 argument to fsac, this will allow you to attach a debugger.",
Expand Down Expand Up @@ -1771,4 +1776,4 @@
"url": "https://github.com/ionide/ionide-vscode-fsharp.git"
},
"version": "7.15.1"
}
}
22 changes: 16 additions & 6 deletions src/Components/Fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,19 @@ module Fsi =

let mutable lastCd: string option = None
let mutable lastCurrentFile: string option = None
let mutable lastCurrentLine: int option = None

let private sendCd (terminal: Terminal) (textEditor: TextEditor option) =
let file, dir =
let file, dir, line =
match textEditor with
| Some textEditor ->
let file = textEditor.document.fileName
let dir = node.path.dirname file
file, dir
let line = int textEditor.selection.start.line + 1
file, dir, line
| None ->
let dir = workspace.rootPath.Value
node.path.join (dir, "tmp.fsx"), dir
node.path.join (dir, "tmp.fsx"), dir, 1

match lastCd with
// Same dir as last time, no need to send it
Expand All @@ -341,15 +343,16 @@ module Fsi =

lastCd <- Some dir

match lastCurrentFile with
match lastCurrentFile, lastCurrentLine with
// Same file as last time, no need to send it
| Some(currentFile) when currentFile = file -> ()
| Some(currentFile), Some(currentLine) when currentFile = file && currentLine = line -> ()
| _ ->
let msg = sprintf "# %d @\"%s\"\n;;\n" 1 file
let msg = sprintf "# %d @\"%s\"\n" line file

terminal.sendText (msg, false)

lastCurrentFile <- Some file
lastCurrentLine <- Some line

let fsiBinaryAndParameters () =
let addWatcher = "FSharp.addFsiWatcher" |> Configuration.get false
Expand Down Expand Up @@ -489,10 +492,17 @@ module Fsi =

let private send (terminal: Terminal) (msg: string) =
let msgWithNewline = msg + (if msg.Contains "//" then "\n" else "") + ";;\n" // TODO: Useful ??
let linesCount = msgWithNewline |> Seq.filter ((=) '\n') |> Seq.length

promise {
terminal.sendText (msgWithNewline, false)
lastSelectionSent <- Some msg

lastCurrentLine <-
match lastCurrentLine with
| Some line -> line + linesCount
| _ -> linesCount + 1
|> Some
}
|> Promise.onFail (fun _ -> window.showErrorMessage ("Failed to send text to FSI") |> ignore)
|> Promise.suppress
Expand Down
7 changes: 5 additions & 2 deletions src/Components/LineLens/PipelineHints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ module PipelineDecorationUpdate =

textLine.range, n.Types, previousTextLine)

/// match something like " 'T1 is int list "
let typeParamRegex = JS.Constructors.RegExp.Create @"'.+?\s.+?\s([\s\S]+)"

let private getSignature (index: int) (range: Vscode.Range, tts: string[]) =
let tt = tts.[index]
let id = tt.IndexOf("is")
let res = tt.Substring(id + 3)
let groups = typeParamRegex.Match(tt).Groups
let res = groups[1].Value
range, " " + res

let private getSignatures (range: Vscode.Range, tts: string[], previousNonPipeLine: Vscode.Range option) =
Expand Down

0 comments on commit 88e9f52

Please sign in to comment.