From 53f4abba2993711fea30bdd38287e3e0ff896d8e Mon Sep 17 00:00:00 2001 From: ijklam Date: Sun, 22 Oct 2023 01:11:08 +0800 Subject: [PATCH] fix and improve add: new FSAC config fullNameExternalAutocomplete to package.json fix: PipelineHint display wrong with localized type param output improve: use correct line number when sending lines to fsi --- release/package.json | 7 ++++++- src/Components/Fsi.fs | 22 ++++++++++++++++------ src/Components/LineLens/PipelineHints.fs | 7 +++++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/release/package.json b/release/package.json index 69955bfa..f84fcf9e 100644 --- a/release/package.json +++ b/release/package.json @@ -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.", @@ -1771,4 +1776,4 @@ "url": "https://github.com/ionide/ionide-vscode-fsharp.git" }, "version": "7.15.1" -} \ No newline at end of file +} diff --git a/src/Components/Fsi.fs b/src/Components/Fsi.fs index bca24f0d..eb93f739 100644 --- a/src/Components/Fsi.fs +++ b/src/Components/Fsi.fs @@ -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 @@ -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 @@ -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 diff --git a/src/Components/LineLens/PipelineHints.fs b/src/Components/LineLens/PipelineHints.fs index 8c06730b..debb6434 100644 --- a/src/Components/LineLens/PipelineHints.fs +++ b/src/Components/LineLens/PipelineHints.fs @@ -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) =