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

Adds setting for FullNameExternalAutocomplete, Fix PipelineHint localization, Fix sending lines to fsi #1952

Merged
merged 1 commit into from
Oct 21, 2023
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
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