fix(editor): corrected editor consuming rebound copy keys preventing custom bindings
- Fixed editor consuming user-rebound copy keys, preventing custom keybindings from working. - Changed copy key detection from generic `tui.input.copy` binding to explicit `ctrl+c` check to avoid swallowing user-rebound keys. - Added test case verifying editor does not consume keys rebound to copy action.
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- Added `renderInlineMarkdown()` function to render inline markdown (bold, italic, code, links, strikethrough) to styled strings
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed editor consuming user-rebound copy keys, preventing custom keybindings from working in the editor
|
||||
|
||||
## [13.14.1] - 2026-03-21
|
||||
### Added
|
||||
|
||||
|
||||
@@ -732,8 +732,10 @@ export class Editor implements Component, Focusable {
|
||||
|
||||
// Handle special key combinations first
|
||||
|
||||
// Ctrl+C - Exit (let parent handle this)
|
||||
if (kb.matches(data, "tui.input.copy")) {
|
||||
// Ctrl+C is reserved by parent components for app-level handling.
|
||||
// Do not consume arbitrary user-bound "copy" keys here, since the editor
|
||||
// has no copy implementation and would make those keys disappear.
|
||||
if (matchesKey(data, "ctrl+c")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1356,6 +1356,23 @@ describe("Editor component", () => {
|
||||
expect(editor.getCursor()).toEqual({ line: 0, col: 0 });
|
||||
});
|
||||
|
||||
it("does not swallow keys rebound to copy", () => {
|
||||
setKeybindings(
|
||||
new KeybindingsManager(TUI_KEYBINDINGS, {
|
||||
"tui.input.copy": "left",
|
||||
}),
|
||||
);
|
||||
|
||||
const editor = new Editor(defaultEditorTheme);
|
||||
editor.setText("ab");
|
||||
|
||||
editor.handleInput("\x1b[D"); // Left arrow
|
||||
editor.handleInput("X");
|
||||
|
||||
expect(editor.getText()).toBe("aXb");
|
||||
expect(editor.getCursor()).toEqual({ line: 0, col: 2 });
|
||||
});
|
||||
|
||||
it("undoes the last paste when a transient #undo trigger is executed", () => {
|
||||
const editor = new Editor(defaultEditorTheme);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user