dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.87k stars 779 forks source link

dotnet FSI should expose the GUI operations "Clear All" and "Reset Interactive Environment" #16742

Open snuup opened 6 months ago

snuup commented 6 months ago

Is your feature request related to a problem? Please describe.

A common working loop is editing fsx files and running parts of such scripts, like

#r "xxx.dll"
... 

let algo() =
    ... some console output here
algo()

In this example, if we execute the code fragment from let algo() ... until the call of algo(), then we hide previous algo instances and rerun the fresh, latest version. So far so good. But to read the output in the F# Interactive output window we often need to search for the begin of the last execution of algo(). The output window gets longer and longer and the effort for this search continually increases. A "Reset interactive Environment" or a "Clear All" with the context menu of the output window clears the window, the reset also removes the accumulated hidden variables.

image

Describe the solution you'd like

I would like to call the 2 operations

from the fsi object. I could then write the script:

fsi.ClearAll()

fsi.ClearAll()
let algo() =                                 
    ... some console output here  
algo()                                         

which avoids switching between keyboard and mouse and fiddling with the context menu. Having

fsi.ResetInteractiveEnvironment()

at the top of the script would easily allow reevaluation of the whole script without leaving the keyboard: Select all text and execute the selected code via keyboard shortcut.

Tangent-90 commented 6 months ago

fsi.ClearAll() maybe is System.Console.Clear()