micro-editor / micro-editor/micro

micro not respecting raw escape sequence bindings

Open
#2,975 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
29.6k
Forks
1.4k
Avg merge
2d 18h
Merged PRs (30d)
10

Description

I have my terminal setup to send certain escape sequences based on some key combinations. Micro is receiving these escape sequences, but seems to still be binding based on micro key names.

For example, I have Super+Shift+Left setup to send \x1b[1;10D. In my bindings.json, I have:

"\u001b[1;10D": "DuplicateLine",

This is what raw shows when I press that key combination:

EventKey: Shift-Alt-Left: "\x1b[1;10D"

Despite showing the right escape sequence, DuplicateLine does not work. However, if I bind AltShiftLeft to DuplicateLine, it works (note that I'm not actually pressing AltShiftLeft).

To better see what's going on, say I had a bindings.json like this:

  "\u001b[1;10D": "InsertNewline",
  "AltShiftLeft": "DuplicateLine",

Pressing the key combination that sends \x1b[1;10D duplicates the line instead of inserting newline.

So it seems like micro is trying to do some translation from escape sequence to key name which doesn't seem like the correct thing to do. It should just match on the actual escape sequence.

Commit hash: c2cebaa3
OS: macOS
Terminal: wezterm 20230712-072601-f4abf8fd

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how bindings.json entries and the raw command's EventKey output are handled at commit c2cebaa3, especially where the escape sequence is translated to a micro key name. Reproduce the macOS/WezTerm example and verify that the literal \u001b[1;10D binding takes precedence over the translated key binding.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.