🐞 [BUG] Raw escape sequences ignored in CommandMode & Alt + Non-Latin layout requires raw Unicode bindings
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
调研方向
报告中没有列出文件、测试或入口点。首先,使用报告中的绑定在主缓冲区和命令窗格中重现原始序列,然后验证命令窗格绑定、非拉丁字符 Alt 绑定以及逻辑上的 Shift-Enter 支持能够正常工作,且不存在重复的原始映射。
由索引模型根据 Issue 内容生成。
描述
Environment
| Field | Value |
|---|---|
| Micro version | 2.0.16-dev.51 (CGO_ENABLED=1) |
| Distro | CachyOS (Arch Linux) |
| Kernel | 7.0.9-1-cachyos |
| CPU | Intel Core i5-1240P |
| GPU | Intel Iris Xe Graphics [ADL GT2] |
| GPU Driver | i915 |
| Mesa | 26.1.1 |
| Compositor | labwc |
My settings.json
{
"*.bak": {
"filetype": "micro"
},
"*.conf": {
"filetype": "ini"
},
"*.txt": {
"filetype": "micro"
},
"autosu": true,
"clipboard": "external",
"colorscheme": "dukedark_mod-tc",
"diffgutter": true,
"ft:asciidoc": {
"tabsize": 2
},
"ft:asm": {
"tabstospaces": false
},
"ft:awk": {
"tabstospaces": false
},
"ft:c": {
"tabsize": 2
},
"ft:c++": {
"tabsize": 2
},
"ft:clojure": {
"tabsize": 2
},
"ft:cmake": {
"tabsize": 2
},
"ft:crystal": {
"tabsize": 2
},
"ft:css": {
"tabsize": 2
},
"ft:cuda": {
"tabstospaces": false
},
"ft:dart": {
"tabsize": 2
},
"ft:ebuild": {
"tabstospaces": false
},
"ft:elixir": {
"tabsize": 2
},
"ft:forth": {
"tabstospaces": false
},
"ft:gdscript": {
"tabstospaces": false
},
"ft:gleam": {
"tabsize": 2
},
"ft:go": {
"tabstospaces": false
},
"ft:gomod": {
"tabstospaces": false
},
"ft:graphql": {
"tabsize": 2
},
"ft:haskell": {
"tabsize": 2
},
"ft:html": {
"tabsize": 2
},
"ft:html5": {
"tabsize": 2
},
"ft:jinja2": {
"tabsize": 2
},
"ft:json": {
"tabsize": 2
},
"ft:jsonnet": {
"tabsize": 2
},
"ft:justfile": {
"tabstospaces": false
},
"ft:lisp": {
"tabsize": 2
},
"ft:lua": {
"tabsize": 2
},
"ft:makefile": {
"tabstospaces": false
},
"ft:markdown": {
"tabsize": 2
},
"ft:meson": {
"tabsize": 2
},
"ft:msbuild": {
"tabsize": 2
},
"ft:nim": {
"tabsize": 2
},
"ft:nix": {
"tabsize": 2
},
"ft:ocaml": {
"tabsize": 2
},
"ft:proto": {
"tabsize": 2
},
"ft:puppet": {
"tabsize": 2
},
"ft:r": {
"tabsize": 2
},
"ft:ruby": {
"tabsize": 2
},
"ft:scala": {
"tabsize": 2
},
"ft:shell": {
"tabsize": 4
},
"ft:svelte": {
"tabsize": 2
},
"ft:terraform": {
"tabsize": 2
},
"ft:tex": {
"tabsize": 2
},
"ft:typescript": {
"tabsize": 2
},
"ft:vue": {
"tabsize": 2
},
"ft:xml": {
"tabsize": 2
},
"ft:yaml": {
"tabsize": 2
},
"ft:zsh": {
"tabsize": 4
},
"helpsplit": "vsplit",
"hlsearch": true,
"matchbracestyle": "highlight",
"mkparents": true,
"parsecursor": true,
"paste": false,
"rmtrailingws": false,
"ruler": false,
"savecursor": false,
"saveundo": false,
"scrollbar": true,
"scrollbarchar": "│",
"scrollspeed": 3,
"smartpaste": true,
"softwrap": true,
"statusformatl": "$(filename) $(modified)$(overwrite) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
"statusformatr": "$(line):$(col) | $(lines) ",
"tabhighlight": false,
"tabmovement": true,
"tabsize": 4,
"tabstospaces": true,
"truecolor": "on",
"useprimary": true,
"wordwrap": true,
"xterm": false
}
My bindings.json
{
"Alt-r": "command:toggle ruler",
"Alt-s": "command:setlocal showchars 'tab=›,space=·'",
"Alt-Ctrl-s": "command:reset showchars",
"Alt-t": "command:togglelocal hltaberrors|command:togglelocal hltrailingws",
"Alt-w": "command:toggle softwrap|command:toggle wordwrap",
"\u001bк": "command:toggle ruler",
"\u001bы": "command:setlocal showchars 'tab=›,space=·'",
"\u001b\u0013": "command:reset showchars",
"\u001bе": "command:togglelocal hltaberrors|command:togglelocal hltrailingws",
"\u001bц": "command:toggle softwrap|command:toggle wordwrap",
"Alt-Enter": "CommandMode",
"\u001b[27;5;13~": "CommandMode",
"\u001b[27;2;13~": "InsertNewline",
"F3": "FindNext",
"Shift-F3": "FindPrevious",
"Alt-Ctrl-Down": "FindNext",
"Alt-Ctrl-Up": "FindPrevious",
"command": {
"Alt-Enter": "AbortCommand",
"\u001b[27;5;13~": "AbortCommand",
"Ctrl-e": "AbortCommand"
}
}
Description
I've encountered two keybinding bugs while configuring Micro in Foot/Kitty with a Cyrillic keyboard layout. Both issues stem from how Micro parses key events internally versus what the terminal actually sends.
Bug 1: Raw escape sequences are ignored in the command pane
Terminals such as Foot or Kitty send specific raw escape sequences for modified keys. For example, Ctrl+Enter sends \x1b[27;5;13~ and Shift+Enter sends \x1b[27;2;13~.
Using the > raw command, I can see Micro receives these sequences correctly in the main buffer. I can bind them in bindings.json:
{
"Alt-Enter": "CommandMode",
"\u001b[27;5;13~": "CommandMode",
"\u001b[27;2;13~": "InsertNewline"
}
This works perfectly in the main buffer. However, to create a toggle for the command mode, I need to bind the same key to AbortCommand inside the "command" pane type:
{
"command": {
"Alt-Enter": "AbortCommand",
"\u001b[27;5;13~": "AbortCommand"
}
}
Expected behavior: Pressing Ctrl+Enter while the command bar is open should execute AbortCommand and close the command bar (just like Alt-Enter does when bound this way).
Actual behavior: The raw escape sequence binding is completely ignored in the command pane. Pressing the key does nothing. The command pane parser does not support matching raw escape sequences the way the main buffer does.
Bug 2: Alt + Non-Latin keys require manual raw Unicode mappings
When using a non-Latin (Cyrillic ru_RU) keyboard layout, pressing Alt + a key sends an escape sequence containing the Unicode character of the Cyrillic letter, not the physical Latin key.
For example, Alt+r on a Cyrillic layout sends \x1bк (because 'к' is on the same physical key as 'r'). Micro does not map this to the logical Alt-r binding. To make it work, I have to manually figure out the raw sequence and duplicate every Alt binding (as seen in my bindings.json above):
{
"Alt-r": "command:toggle ruler",
"\u001bк": "command:toggle ruler"
}
Expected behavior: Micro should ideally map keybindings based on the physical key position, or at least provide a mechanism to define layout-agnostic bindings so users don't have to duplicate all Alt bindings with raw Unicode codes.
Actual behavior: Users with non-Latin layouts must duplicate all Alt keybindings using raw \u001b<unicode_char> sequences, making the config bloated and hard to maintain.
And a few small requests ...
Feature Request 1: Native Shift-Enter support
Currently, to make Shift+Enter insert a newline, users of Foot/Kitty have to manually bind the raw escape sequence (\u001b[27;2;13~) to InsertNewline. It would be much more user-friendly if Micro natively supported the logical binding "Shift-Enter": "InsertNewline" out of the box, abstracting away the terminal-specific escape sequences.
Summary of requested changes:
- Fix: Allow raw escape sequence bindings (like
\u001b[27;5;13~) to work inside the"command"pane type. - Fix: Improve handling of
Altmodifiers for non-Latin keyboard layouts (physical key mapping). - Feature: Add native support for
"Shift-Enter": "InsertNewline"without requiring raw escape hacks.
Thank you for your time and for maintaining the best editor!
- 主要语言
- Go
- 星标
- 29.8k
- 派生
- 1.4k
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
micro-editor/micro 的其他 Issue
-
feature syntax
难度 2/5 1-3 小时 新手友好度 72/100
micro-editor/micro#4289 ·
维护者通常 3 天内回复
-
Also bind alt-click for multi-cursors可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭feature
难度 2/5 1-3 小时 新手友好度 68/100
micro-editor/micro#4260 ·
维护者通常 3 天内回复
-
XML syntax highlighting breaks if empty tag contains whitespace before close可能已有人在做 @justadityaraj 于 59 天前认领。 未关闭bug syntax
难度 2/5 1-3 小时 新手友好度 68/100
micro-editor/micro#4213 · 1 条评论 ·
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 78/100
micro-editor/micro#3553 · 5 条评论 ·
维护者通常 3 天内回复
-
syntax
难度 2/5 1-3 小时 新手友好度 64/100
micro-editor/micro#2969 · 3 条评论 · 1 个 reaction ·
维护者通常 3 天内回复
查看 micro-editor/micro 的全部 Issue
相似的 Issue
-
govulncheck reports 7 reachable vulnerabilities in dependencies可能已有人在做 @dwisiswant0 今天认领。 未关闭Type: Bug
难度 2/5 1-3 小时 新手友好度 76/100
projectdiscovery/rawhttp#558 ·
-
govulncheck reports 8 vulnerabilities in called code可能已有人在做 @dwisiswant0 今天认领。 未关闭Type: Bug
难度 2/5 1-3 小时 新手友好度 73/100
projectdiscovery/vulnx#517 ·
-
难度 2/5 1-3 小时 新手友好度 66/100
-
Type: Bug
难度 2/5 1-3 小时 新手友好度 67/100
-
难度 2/5 1-3 小时 新手友好度 77/100
rubys/roundhouse#1946 ·