continuity_engine/selection_edit.rs
1//! Selection-aware edit planning for the synchronous engine.
2//!
3//! Every command that mutates buffer text routes through here. The public
4//! [`SelectionEdit`] enum names the operation; [`plan`] turns it into a
5//! [`SelectionEditPlan`] of atomic [`EditOp`]s in **descending byte order**
6//! (so sequential `Buffer::apply` calls keep their pre-edit offsets valid)
7//! plus the post-edit selection set; [`apply_plan`] runs the ops against a
8//! mutable buffer and returns the final revision.
9//!
10//! Per-family planners (newlines, word-scope deletes, line ops, inline
11//! shape edits, markdown) live in sibling modules to keep this file under
12//! the 600-line cap.
13
14use continuity_buffer::{Buffer, Revision};
15use continuity_text::{EditOp, Selection};
16use ropey::Rope;
17
18use crate::edit_inline::{
19 plan_change_case, plan_delete_to_bracket, plan_reflow_paragraph, plan_surround_selection,
20 plan_transpose_chars, plan_wrap_at_column,
21};
22use crate::edit_line_text::{
23 plan_convert_line_endings, plan_indent, plan_outdent, plan_reverse_lines, plan_shuffle_lines,
24 plan_sort_lines, plan_spaces_to_tabs, plan_tabs_to_spaces, plan_trim_trailing_whitespace,
25 plan_trim_trailing_whitespace_all, plan_trim_whitespace_all, plan_unique_lines,
26};
27use crate::edit_lines::{
28 plan_delete_to_line_end, plan_delete_to_line_start, plan_duplicate_line,
29 plan_duplicate_selection, plan_insert_newline_above, plan_insert_newline_below,
30 plan_insert_newline_smart, plan_join_lines, plan_join_selected_lines, plan_move_line_down,
31 plan_move_line_up, plan_toggle_bullet_at_line_start,
32 plan_toggle_bullet_with_continuation_indent,
33};
34use crate::edit_markdown::{
35 plan_markdown_cycle_list_marker, plan_markdown_insert_code_fence,
36 plan_markdown_insert_image_ref, plan_markdown_insert_link, plan_markdown_toggle_checkbox,
37 plan_markdown_toggle_emphasis, plan_markdown_toggle_numbered, plan_markdown_toggle_task,
38 plan_markdown_wrap_in_blockquote,
39};
40use crate::edit_markdown_blocks::{
41 plan_markdown_cycle_heading, plan_markdown_demote_section, plan_markdown_move_section_down,
42 plan_markdown_move_section_up, plan_markdown_promote_section, plan_markdown_set_heading,
43};
44use crate::edit_pairs::{plan_delete_pair, plan_insert_pair};
45use crate::edit_planning::{
46 caret_delete_range, finalize_specs_with_transformed_selections, merge_specs,
47 ranges_for_selection, EditSpec,
48};
49use crate::edit_words::{
50 plan_delete_word_backward, plan_delete_word_forward, plan_transpose_words,
51};
52use crate::Error;
53
54/// A selection-aware edit requested by an editor command.
55///
56/// New variants land here as commands graduate from "named in spec" to
57/// "implemented". Each variant maps to exactly one undo group.
58#[derive(Clone, Debug, PartialEq, Eq)]
59pub enum SelectionEdit {
60 /// Insert or replace each active selection with the supplied text.
61 InsertText(String),
62 /// Delete the selected text, or one character before each caret.
63 DeleteBack,
64 /// Delete the selected text, or one character after each caret.
65 DeleteForward,
66
67 /// Insert a newline on a fresh line above each selection's line, with
68 /// the caret landing on the new line.
69 InsertNewlineAbove,
70 /// Insert a newline on a fresh line below each selection's line, caret
71 /// at the new line.
72 InsertNewlineBelow,
73 /// Insert a newline that inherits the leading indentation of the
74 /// caret's current line.
75 InsertNewlineSmart,
76
77 /// Toggle a `- ` bullet marker right after each selection line's
78 /// leading whitespace. Adding the marker shifts the caret's byte
79 /// column by `+2` so the cursor stays on the same content character
80 /// (visually unchanged). Removing it shifts by `-2` (clamped to the
81 /// leading-whitespace column). Plain-text variant of
82 /// [`SelectionEdit::MarkdownToggleBullet`] — it doesn't depend on
83 /// markdown parse state and is meant for the Ctrl+R quick-toggle
84 /// shortcut.
85 ToggleBulletAtLineStart,
86
87 /// Like [`SelectionEdit::ToggleBulletAtLineStart`], but for a multi-line
88 /// selection the add path also prepends one indent unit to every covered
89 /// line after the first (turning the selection into a bulleted list whose
90 /// continuation lines are indented under the first item); the strip path
91 /// removes both the bullet and that indent. A single-line selection
92 /// behaves identically to the plain toggle. Bound to `Ctrl+Shift+R`.
93 ToggleBulletWithContinuationIndent {
94 /// Indent unit (tab or N spaces) prepended to continuation lines,
95 /// read live from the dispatch context (mirrors `editor.indent`).
96 unit: IndentUnit,
97 },
98
99 /// Delete text from the caret backward to the previous word boundary.
100 DeleteWordBackward,
101 /// Delete text from the caret forward to the next word boundary.
102 DeleteWordForward,
103 /// Delete from the caret back to the start of the line (or first
104 /// non-whitespace if already at line start).
105 DeleteToLineStart,
106 /// Delete from the caret forward to the end of the line.
107 DeleteToLineEnd,
108 /// Delete from the caret to the matching bracket, if any.
109 DeleteToBracket,
110
111 /// Duplicate the entire line(s) covered by each selection.
112 DuplicateLine,
113 /// Duplicate the bytes spanned by each selection (caret selections
114 /// duplicate nothing).
115 DuplicateSelection,
116 /// Move each selected line up one position.
117 MoveLineUp,
118 /// Move each selected line down one position.
119 MoveLineDown,
120 /// Join the line below each selection's line into the current line.
121 JoinLines,
122 /// Collapse every line break within the lines covered by each selection
123 /// into a single space, joining the whole selected block into one line
124 /// (VS Code "Join Lines"). Distinct from [`SelectionEdit::JoinLines`],
125 /// which only folds the single line below each caret (Vim `J`).
126 JoinSelectedLines,
127 /// Sort the lines covered by selections.
128 SortLines(SortKind),
129 /// Reverse the order of lines covered by selections.
130 ReverseLines,
131 /// Drop duplicate lines covered by selections (case-sensitive, stable).
132 UniqueLines,
133 /// Pseudo-randomly reorder the lines covered by selections, seeded for
134 /// determinism (the seed is hashed into the LCG).
135 ShuffleLines(u64),
136 /// Trim trailing whitespace from every line covered by selections.
137 TrimTrailingWhitespace,
138 /// Phase B14: trim trailing whitespace on every line in the buffer
139 /// regardless of selection. Used by the explicit
140 /// `editor.trim_trailing_whitespace` command and the on-save hook.
141 TrimTrailingWhitespaceAll,
142 /// Strip leading **and** trailing whitespace from every line in the
143 /// buffer (one undo group). Used by the explicit `editor.trim_whitespace`
144 /// command. Per-line leading strip removes indentation by design — the
145 /// literal "trim each line" reading, distinct from
146 /// [`SelectionEdit::TrimTrailingWhitespaceAll`].
147 TrimWhitespaceAll,
148
149 /// Hard-wrap each paragraph covered by selections at `column` columns.
150 WrapAtColumn(u32),
151 /// Reflow each paragraph at `column` columns, preserving leading
152 /// whitespace.
153 ReflowParagraph(u32),
154
155 /// Transpose the two characters straddling each caret.
156 TransposeChars,
157 /// Transpose the two words straddling each caret.
158 TransposeWords,
159
160 /// Change case of the bytes inside each selection (or the word at each
161 /// caret).
162 ChangeCase(CaseKind),
163
164 /// Indent each selected line by one indent unit.
165 Indent {
166 /// Indent unit (tab or N spaces).
167 unit: IndentUnit,
168 },
169 /// Outdent each selected line by one indent unit.
170 Outdent {
171 /// Indent unit (tab or N spaces).
172 unit: IndentUnit,
173 },
174
175 /// Replace runs of `tab_width` spaces with tabs.
176 SpacesToTabs {
177 /// Number of contiguous spaces that map to one tab.
178 tab_width: u32,
179 },
180 /// Replace tabs with `tab_width` spaces.
181 TabsToSpaces {
182 /// Number of spaces emitted per tab.
183 tab_width: u32,
184 },
185 /// Convert line endings of every covered line.
186 ConvertLineEndings(LineEnding),
187 /// Phase C2 — convert line endings on every line in the buffer
188 /// regardless of selection. Used by the status-bar click handler
189 /// and the C3 mixed-LE normalize chip.
190 ConvertLineEndingsAll(LineEnding),
191 /// Phase C3 — replace every tab in the buffer with `tab_width`
192 /// spaces, regardless of selection. Used by the mixed-indent
193 /// normalize chip.
194 TabsToSpacesAll {
195 /// Number of spaces emitted per tab.
196 tab_width: u32,
197 },
198
199 /// Wrap each non-empty selection in `open` … `close`.
200 SurroundSelection {
201 /// Inserted at the start of the selection.
202 open: String,
203 /// Inserted at the end of the selection.
204 close: String,
205 },
206
207 /// Toggle markdown emphasis around each selection.
208 MarkdownToggleEmphasis(EmphasisKind),
209 /// Set the heading level of each covered line. `level == 0` strips the
210 /// heading; `1..=6` rewrites the prefix.
211 MarkdownSetHeading(u8),
212 /// Cycle the heading level on each covered line (`+1`/`-1`).
213 MarkdownCycleHeading(i32),
214 /// Promote (decrease level) the section enclosing each caret.
215 MarkdownPromoteSection,
216 /// Demote (increase level) the section enclosing each caret.
217 MarkdownDemoteSection,
218 /// Move the section enclosing each caret upward past the previous
219 /// sibling section.
220 MarkdownMoveSectionUp,
221 /// Move the section enclosing each caret downward past the next
222 /// sibling section.
223 MarkdownMoveSectionDown,
224 /// Toggle a `- ` bullet prefix on each covered line. Shares the
225 /// content-relative planner with [`SelectionEdit::ToggleBulletAtLineStart`]
226 /// (`plan_toggle_bullet_at_line_start`), so the caret stays on the same
227 /// content character across add/remove and an ordered→bullet conversion.
228 MarkdownToggleBullet,
229 /// Toggle a `1. ` numbered prefix on each covered line.
230 MarkdownToggleNumbered,
231 /// Toggle a `[ ]`/`[x]` checkbox prefix on each covered line.
232 MarkdownToggleCheckbox,
233 /// Toggle a `- [ ] ` task-bullet prefix on each covered line: plain
234 /// or bulleted lines gain the task marker; existing task lines drop
235 /// it. Bound to `Ctrl+E`.
236 MarkdownToggleTask,
237 /// Cycle the list marker between `-`, `*`, `+`.
238 MarkdownCycleListMarker,
239 /// Phase B11: renumber the ordered list containing the caret.
240 MarkdownRenumberList,
241 /// Prefix `> ` on each covered line.
242 MarkdownWrapInBlockquote,
243 /// Wrap selections in fenced code blocks (or insert an empty fence).
244 MarkdownInsertCodeFence,
245 /// Wrap each non-empty selection as `[text](url)` with placeholder url.
246 MarkdownInsertLink,
247 /// Insert `` at each caret.
248 MarkdownInsertImageRef,
249 /// Strip markdown formatting from every covered line: heading
250 /// hashes, list/checkbox markers, blockquote prefixes, emphasis /
251 /// code / strikethrough delimiters, and link syntax (keeping the
252 /// link text). Conservative on intraword `_` / lone `*` so code
253 /// identifiers and arithmetic survive.
254 MarkdownStripFormatting,
255
256 /// Phase-16.5 auto-pair insert: at each caret, insert `open`
257 /// immediately followed by `close`, leaving the caret between
258 /// them. Lands as one undo group. Selections that already cover a
259 /// non-empty range fall back to surrounding the range with
260 /// `open` … `close` (so highlight + `(` keeps the surround
261 /// behavior of [`Self::SurroundSelection`]).
262 InsertPair {
263 /// Leading character (e.g. `(`).
264 open: String,
265 /// Trailing character (e.g. `)`).
266 close: String,
267 },
268 /// Phase-16.5 backspace-aware delete-pair: at each caret, if the
269 /// preceding byte is `open` and the following byte is `close`,
270 /// delete both as one undo group. Otherwise the planner returns
271 /// `Ok(None)` so the caller can fall through to a normal
272 /// [`Self::DeleteBack`].
273 DeletePair {
274 /// Open delimiter to the left of the caret.
275 open: char,
276 /// Close delimiter to the right of the caret.
277 close: char,
278 },
279}
280
281/// Sort variant used by [`SelectionEdit::SortLines`].
282#[derive(Copy, Clone, Debug, PartialEq, Eq)]
283pub enum SortKind {
284 /// Ascending, case-sensitive byte order.
285 Asc,
286 /// Descending, case-sensitive byte order.
287 Desc,
288 /// Ascending, case-insensitive.
289 AscCaseInsensitive,
290 /// Descending, case-insensitive.
291 DescCaseInsensitive,
292 /// Ascending, by ASCII length.
293 AscByLength,
294 /// Descending, by ASCII length.
295 DescByLength,
296 /// Ascending, natural-numeric (digit runs as integers).
297 AscNumeric,
298 /// Descending, natural-numeric.
299 DescNumeric,
300}
301
302/// Case-conversion kinds.
303#[derive(Copy, Clone, Debug, PartialEq, Eq)]
304pub enum CaseKind {
305 /// `EXAMPLE`.
306 Upper,
307 /// `example`.
308 Lower,
309 /// `Example Title`.
310 Title,
311 /// Invert the case of each ASCII letter.
312 Toggle,
313 /// `Example. case.` — first letter of each sentence uppercased.
314 Sentence,
315}
316
317/// Indent unit used by [`SelectionEdit::Indent`] / [`SelectionEdit::Outdent`].
318#[derive(Copy, Clone, Debug, PartialEq, Eq)]
319pub enum IndentUnit {
320 /// One tab character.
321 Tab,
322 /// `n` spaces.
323 Spaces(u32),
324}
325
326/// Line-ending convention.
327#[derive(Copy, Clone, Debug, PartialEq, Eq)]
328pub enum LineEnding {
329 /// `\n`.
330 Lf,
331 /// `\r\n`.
332 Crlf,
333}
334
335/// Markdown emphasis flavor.
336#[derive(Copy, Clone, Debug, PartialEq, Eq)]
337pub enum EmphasisKind {
338 /// `**text**`.
339 Bold,
340 /// `*text*`.
341 Italic,
342 /// `~~text~~`.
343 Strikethrough,
344 /// `` `text` ``.
345 InlineCode,
346}
347
348/// A planned selection edit against one immutable pre-edit buffer state.
349pub struct SelectionEditPlan {
350 /// Atomic edit ops to apply, ordered from highest byte offset to lowest.
351 pub ops: Vec<EditOp>,
352 /// Selection set before the edit.
353 pub selections_before: Vec<Selection>,
354 /// Selection set after the whole edit group.
355 pub selections_after: Vec<Selection>,
356}
357
358/// Build atomic edit ops for a selection-aware edit.
359///
360/// Returns `Ok(None)` when the operation has no effect (e.g. backspace at
361/// the document start with all carets at offset 0).
362///
363/// # Errors
364///
365/// Returns core errors when any selection position is outside the buffer,
366/// or argument validation fails (e.g. an out-of-range heading level).
367pub fn plan(buffer: &Buffer, edit: &SelectionEdit) -> Result<Option<SelectionEditPlan>, Error> {
368 match edit {
369 SelectionEdit::InsertText(text) => plan_insert_text(buffer, text),
370 SelectionEdit::DeleteBack => plan_delete(buffer, true),
371 SelectionEdit::DeleteForward => plan_delete(buffer, false),
372
373 SelectionEdit::InsertNewlineAbove => plan_insert_newline_above(buffer),
374 SelectionEdit::InsertNewlineBelow => plan_insert_newline_below(buffer),
375 SelectionEdit::InsertNewlineSmart => plan_insert_newline_smart(buffer),
376 SelectionEdit::ToggleBulletAtLineStart => plan_toggle_bullet_at_line_start(buffer),
377 SelectionEdit::ToggleBulletWithContinuationIndent { unit } => {
378 let indent_unit = crate::edit_line_text_helpers::indent_text(*unit);
379 plan_toggle_bullet_with_continuation_indent(buffer, &indent_unit)
380 }
381
382 SelectionEdit::DeleteWordBackward => plan_delete_word_backward(buffer),
383 SelectionEdit::DeleteWordForward => plan_delete_word_forward(buffer),
384 SelectionEdit::DeleteToLineStart => plan_delete_to_line_start(buffer),
385 SelectionEdit::DeleteToLineEnd => plan_delete_to_line_end(buffer),
386 SelectionEdit::DeleteToBracket => plan_delete_to_bracket(buffer),
387
388 SelectionEdit::DuplicateLine => plan_duplicate_line(buffer),
389 SelectionEdit::DuplicateSelection => plan_duplicate_selection(buffer),
390 SelectionEdit::MoveLineUp => plan_move_line_up(buffer),
391 SelectionEdit::MoveLineDown => plan_move_line_down(buffer),
392 SelectionEdit::JoinLines => plan_join_lines(buffer),
393 SelectionEdit::JoinSelectedLines => plan_join_selected_lines(buffer),
394 SelectionEdit::SortLines(kind) => plan_sort_lines(buffer, *kind),
395 SelectionEdit::ReverseLines => plan_reverse_lines(buffer),
396 SelectionEdit::UniqueLines => plan_unique_lines(buffer),
397 SelectionEdit::ShuffleLines(seed) => plan_shuffle_lines(buffer, *seed),
398 SelectionEdit::TrimTrailingWhitespace => plan_trim_trailing_whitespace(buffer),
399 SelectionEdit::TrimTrailingWhitespaceAll => plan_trim_trailing_whitespace_all(buffer),
400 SelectionEdit::TrimWhitespaceAll => plan_trim_whitespace_all(buffer),
401
402 SelectionEdit::WrapAtColumn(width) => plan_wrap_at_column(buffer, *width),
403 SelectionEdit::ReflowParagraph(width) => plan_reflow_paragraph(buffer, *width),
404
405 SelectionEdit::TransposeChars => plan_transpose_chars(buffer),
406 SelectionEdit::TransposeWords => plan_transpose_words(buffer),
407
408 SelectionEdit::ChangeCase(kind) => plan_change_case(buffer, *kind),
409
410 SelectionEdit::Indent { unit } => plan_indent(buffer, *unit),
411 SelectionEdit::Outdent { unit } => plan_outdent(buffer, *unit),
412
413 SelectionEdit::SpacesToTabs { tab_width } => plan_spaces_to_tabs(buffer, *tab_width),
414 SelectionEdit::TabsToSpaces { tab_width } => plan_tabs_to_spaces(buffer, *tab_width),
415 SelectionEdit::ConvertLineEndings(eol) => plan_convert_line_endings(buffer, *eol),
416 SelectionEdit::ConvertLineEndingsAll(eol) => {
417 crate::edit_normalize::plan_convert_line_endings_all(buffer, *eol)
418 }
419 SelectionEdit::TabsToSpacesAll { tab_width } => {
420 crate::edit_normalize::plan_tabs_to_spaces_all(buffer, *tab_width)
421 }
422
423 SelectionEdit::SurroundSelection { open, close } => {
424 plan_surround_selection(buffer, open, close)
425 }
426
427 SelectionEdit::MarkdownToggleEmphasis(kind) => plan_markdown_toggle_emphasis(buffer, *kind),
428 SelectionEdit::MarkdownSetHeading(level) => plan_markdown_set_heading(buffer, *level),
429 SelectionEdit::MarkdownCycleHeading(delta) => plan_markdown_cycle_heading(buffer, *delta),
430 SelectionEdit::MarkdownPromoteSection => plan_markdown_promote_section(buffer),
431 SelectionEdit::MarkdownDemoteSection => plan_markdown_demote_section(buffer),
432 SelectionEdit::MarkdownMoveSectionUp => plan_markdown_move_section_up(buffer),
433 SelectionEdit::MarkdownMoveSectionDown => plan_markdown_move_section_down(buffer),
434 SelectionEdit::MarkdownToggleBullet => plan_toggle_bullet_at_line_start(buffer),
435 SelectionEdit::MarkdownToggleNumbered => plan_markdown_toggle_numbered(buffer),
436 SelectionEdit::MarkdownToggleCheckbox => plan_markdown_toggle_checkbox(buffer),
437 SelectionEdit::MarkdownToggleTask => plan_markdown_toggle_task(buffer),
438 SelectionEdit::MarkdownCycleListMarker => plan_markdown_cycle_list_marker(buffer),
439 SelectionEdit::MarkdownRenumberList => {
440 crate::edit_list::plan_markdown_renumber_list(buffer)
441 }
442 SelectionEdit::MarkdownWrapInBlockquote => plan_markdown_wrap_in_blockquote(buffer),
443 SelectionEdit::MarkdownInsertCodeFence => plan_markdown_insert_code_fence(buffer),
444 SelectionEdit::MarkdownInsertLink => plan_markdown_insert_link(buffer),
445 SelectionEdit::MarkdownInsertImageRef => plan_markdown_insert_image_ref(buffer),
446 SelectionEdit::MarkdownStripFormatting => {
447 crate::edit_markdown_strip::plan_markdown_strip_formatting(buffer)
448 }
449
450 SelectionEdit::InsertPair { open, close } => plan_insert_pair(buffer, open, close),
451 SelectionEdit::DeletePair { open, close } => plan_delete_pair(buffer, *open, *close),
452 }
453}
454
455/// Apply already-planned ops and assign the final selection set.
456///
457/// # Errors
458///
459/// Returns buffer-layer errors if an op is invalid against the current
460/// buffer state.
461pub fn apply_plan(
462 buffer: &mut Buffer,
463 plan: &SelectionEditPlan,
464) -> Result<Option<Revision>, Error> {
465 let mut last = None;
466 for op in &plan.ops {
467 last = Some(buffer.apply(op)?);
468 }
469 let mut selections = plan.selections_after.clone();
470 crate::selection_coalesce::coalesce_selections(&mut selections);
471 buffer.set_selections(selections);
472 Ok(last)
473}
474
475fn plan_insert_text(buffer: &Buffer, text: &str) -> Result<Option<SelectionEditPlan>, Error> {
476 let selections_before = buffer.selections().to_vec();
477 let specs = insert_specs(buffer.rope(), &selections_before, text)?;
478 Ok(finalize_specs_with_transformed_selections(
479 specs,
480 selections_before,
481 ))
482}
483
484fn plan_delete(buffer: &Buffer, backward: bool) -> Result<Option<SelectionEditPlan>, Error> {
485 let selections_before = buffer.selections().to_vec();
486 let mut specs = delete_specs(buffer.rope(), &selections_before, backward)?;
487 if specs.is_empty() {
488 return Ok(None);
489 }
490 specs.sort_by_key(|spec| spec.start);
491 specs = merge_specs(specs);
492 let selections_after = specs
493 .iter()
494 .map(|spec| Selection::caret_at(spec.start_position))
495 .collect();
496 let ops = specs.into_iter().rev().map(EditSpec::into_op).collect();
497 Ok(Some(SelectionEditPlan {
498 ops,
499 selections_before,
500 selections_after,
501 }))
502}
503
504fn insert_specs(rope: &Rope, selections: &[Selection], text: &str) -> Result<Vec<EditSpec>, Error> {
505 let mut specs = Vec::new();
506 for selection in selections {
507 for range in ranges_for_selection(rope, *selection)? {
508 let start = range.start.to_byte_offset(rope)?;
509 let end = range.end.to_byte_offset(rope)?;
510 specs.push(EditSpec {
511 start,
512 end,
513 start_position: range.start,
514 inserted: text.to_string(),
515 end_position_in_rope: Some(range.end),
516 });
517 }
518 }
519 Ok(specs)
520}
521
522fn delete_specs(
523 rope: &Rope,
524 selections: &[Selection],
525 backward: bool,
526) -> Result<Vec<EditSpec>, Error> {
527 let mut specs = Vec::new();
528 for selection in selections {
529 for range in ranges_for_selection(rope, *selection)? {
530 let start = range.start.to_byte_offset(rope)?;
531 let end = range.end.to_byte_offset(rope)?;
532 if start != end {
533 specs.push(EditSpec {
534 start,
535 end,
536 start_position: range.start,
537 inserted: String::new(),
538 end_position_in_rope: Some(range.end),
539 });
540 continue;
541 }
542 let Some((delete_start, delete_end)) = caret_delete_range(rope, start, backward) else {
543 continue;
544 };
545 specs.push(EditSpec::delete(rope, delete_start, delete_end)?);
546 }
547 }
548 Ok(specs)
549}
550
551// Tests live in `selection_edit/tests.rs` so this file stays under the
552// 600-line cap.
553#[cfg(test)]
554mod tests;