Skip to content
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
27 changes: 27 additions & 0 deletions src/fsharp/fsi/console.fs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,27 @@ type internal ReadLineConsole() =
if (input.Length > 0 && current < input.Length) then
input.Remove(current, 1) |> ignore
render()

let deleteFromStartOfLineToCursor() =
if (input.Length > 0 && current > 0) then
input.Remove (0, current) |> ignore
current <- 0
render()

let deleteWordLeadingToCursor() =
if (input.Length > 0 && current > 0) then
let line = input.ToString()
let rec prevWord (idx, isInWord) =
if idx < 0 then 0 else
match line.Chars(idx), isInWord with
| ' ', true -> idx + 1
| ' ', false -> prevWord (idx - 1, false)
| _, _ -> prevWord (idx - 1, true)

let idx = prevWord (current - 1, false)
input.Remove(idx, current - idx) |> ignore
current <- idx
render()

let deleteToEndOfLine() =
if (current < input.Length) then
Expand Down Expand Up @@ -452,6 +473,12 @@ type internal ReadLineConsole() =
| (ConsoleModifiers.Control, ConsoleKey.L) ->
clear()
change()
| (ConsoleModifiers.Control, ConsoleKey.U) ->
deleteFromStartOfLineToCursor()
change()
| (ConsoleModifiers.Control, ConsoleKey.W) ->
deleteWordLeadingToCursor()
change()
| _ ->
// Note: If KeyChar=0, the not a proper char, e.g. it could be part of a multi key-press character,
// e.g. e-acute is ' and e with the French (Belgium) IME and US Intl KB.
Expand Down