Allow inserting text into the editor via the action (#16131)
Improves workflows, based on the keymaps that group actions behind a certain symbol. E.g. ```json5 ", o k": "zed::OpenKeymap", ", o K": "zed::OpenDefaultKeymap", // other `,`-based keymaps ``` Now, it's possible to do ```json ", ,": ["editor::HandleInput", ","] ``` and type `,` without waiting for the timeout due to `,`-based bindings. Release Notes: - Add an `editor::HandleInput` action to ease typing symbols that are part of keymaps. E.g. if `, o k` keybinding is bound, `", ,": ["editor::HandleInput", ","]` would allow to type `,` without timeouts. --------- Co-authored-by: Alex Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
co-authored by
Alex Kladov
parent
a3c79218c4
commit
f398ecc3fb
@@ -22,9 +22,9 @@ use crate::{
|
||||
BlockId, CodeActionsMenu, CursorShape, CustomBlockId, DisplayPoint, DisplayRow,
|
||||
DocumentHighlightRead, DocumentHighlightWrite, Editor, EditorMode, EditorSettings,
|
||||
EditorSnapshot, EditorStyle, ExpandExcerpts, FocusedBlock, GutterDimensions, HalfPageDown,
|
||||
HalfPageUp, HoveredCursor, HoveredHunk, LineDown, LineUp, OpenExcerpts, PageDown, PageUp,
|
||||
Point, RangeToAnchorExt, RowExt, RowRangeExt, SelectPhase, Selection, SoftWrap, ToPoint,
|
||||
CURSORS_VISIBLE_FOR, MAX_LINE_LEN,
|
||||
HalfPageUp, HandleInput, HoveredCursor, HoveredHunk, LineDown, LineUp, OpenExcerpts, PageDown,
|
||||
PageUp, Point, RangeToAnchorExt, RowExt, RowRangeExt, SelectPhase, Selection, SoftWrap,
|
||||
ToPoint, CURSORS_VISIBLE_FOR, MAX_LINE_LEN,
|
||||
};
|
||||
use client::ParticipantIndex;
|
||||
use collections::{BTreeMap, HashMap};
|
||||
@@ -231,6 +231,12 @@ impl EditorElement {
|
||||
register_action(view, cx, |editor, _: &HalfPageDown, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(0.5), cx)
|
||||
});
|
||||
register_action(view, cx, |editor, HandleInput(text): &HandleInput, cx| {
|
||||
if text.is_empty() {
|
||||
return;
|
||||
}
|
||||
editor.handle_input(&text, cx);
|
||||
});
|
||||
register_action(view, cx, |editor, _: &HalfPageUp, cx| {
|
||||
editor.scroll_screen(&ScrollAmount::Page(-0.5), cx)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user