Skip to content

Commit

Permalink
do not block next text input, as handled flag will already do that.
Browse files Browse the repository at this point in the history
  • Loading branch information
yatli committed Mar 13, 2022
1 parent 9f975b6 commit 06ef298
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions input.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ let DIR (dx: float, dy: float, horizontal: bool) =

let mutable accumulatedX = 0.0
let mutable accumulatedY = 0.0
let mutable blockNextTextInput = false

// Avoid sending Rejected key as a sequence, e.g. "capslock"
let RejectKeys = set [
Expand Down Expand Up @@ -284,17 +283,12 @@ let (|Special|Normal|Rejected|) (x: InputEvent) =
// | ' | ' | ä |
// | Ctrl-' | <C-'> | <C-'> |
//
| Key(m, Key.Back) ->
if m = KeyModifiers.Control then
blockNextTextInput <- true
Special "BS"
| Key(m, Key.Back) -> Special "BS"
| Key(_, Key.Tab) -> Special "Tab"
| Key(_, Key.LineFeed) -> Special "NL"
| Key(_, Key.Return) -> Special "CR"
| Key(_, Key.Escape) -> Special "Esc"
| Key(_, Key.Space) ->
blockNextTextInput <- true
Special "Space"
| Key(_, Key.Space) -> Special "Space"
| Key(HasFlag(KeyModifiers.Shift), Key.OemComma) -> Special "LT"
// note, on Windows '\' is recognized as OemPipe but on macOS it's OemBackslash
| Key(NoFlag(KeyModifiers.Shift),
Expand Down Expand Up @@ -387,7 +381,7 @@ let rec ModifiersPrefix (x: InputEvent) =
->
let c = if m.HasFlag(KeyModifiers.Control) then "C-" else ""
let a = if m.HasFlag(KeyModifiers.Alt) then "A-" else ""
let d = if m.HasFlag(KeyModifiers.Meta) then "D-" else ""
let d = if m.HasFlag(KeyModifiers.Meta) then "D-" else ""
let s = if m.HasFlag(KeyModifiers.Shift) then "S-" else ""
(sprintf "%s%s%s%s" c a d s).TrimEnd('-')
| TextInput _ -> ""
Expand All @@ -402,12 +396,7 @@ let onInput (nvim: Nvim) (input: IObservable<int*InputEvent*RoutedEventArgs>) =
match x with
| TextInput txt ->
ev.Handled <- true
if txt = "<" then Some "<LT>"
else if blockNextTextInput then
blockNextTextInput <- false
None
else
Some txt
if txt = "<" then Some "<LT>" else Some txt
| InputEvent.Key _ ->
ev.Handled <- true
let pref = ModifiersPrefix x
Expand Down

0 comments on commit 06ef298

Please sign in to comment.