haskell / haskell/haskeline

haskeline interpreting input starting with Esc as terminal function key sequences when they're not?

Open
#199 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Haskell
Stars
247
Forks
82
PR merge metrics
No merged PRs in 30d

Description

Test configuration:
* My `~/.haskeline` contains just `editMode: vi` and comments (lines starting with `#`). I have confirmed it's being read by noting that the Emacs sequences Ctrl-F and Ctrl-B do not work, and start working if I comment out `editMode: vi`.
* I am using Stack `resolver: lts-23.24` and `compiler: ghc-9.8.2`, though the problem seems the same with the default ghc-9.8.4 provided by that resolver.
* I am in a urxvt terminal window and have `TERM=rxvt-unicode-256color` set in my environment, though I get the same behaviour with `TERM=xterm` or even `TERM=` (no terminal set).

When I type e.g. `Esc`, `k` quickly this seems to be interpreted as a terminal function key sequence and I get a visual bell in response. Delaying for a substantial fraction of a second between the two characters (until I see the cursor move after typing `Esc`) does seem to correctly put me in vi normal ("command") mode.

However, I am pretty sure that, `Esc`, `k`, is not the start of a terminal function key sequence for any of the terminal definitions I've tried (and I am certain it's not for `TERM=`). Ought not Haskeline, when it reads an `Esc` followed by a character that cannot be the second character of a valid terminal function key sequence, interpret this as individual characters typed by the user? Is there a way to make this happen?

As a workaround, I'd personally be ok with being able to set the equivalent of readline's `set-keymap-timeout` to 0, but I cannot find such a configuration setting in the Wiki. And anyway that's still a poor solution since it would disable arrow keys etc. entirely and this would greatly annoy at least some people that I pair-program with.

There may be further discussion of this [in this forum post](https://discourse.haskell.org/t/why-is-ghci-not-honouring-my-haskeline/12270) as well.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.