1use std::ops::Range;
2
3use editor::{char_kind, display_map::DisplaySnapshot, movement, Bias, CharKind, DisplayPoint};
4use gpui::{actions, impl_actions, AppContext, WindowContext};
5use language::Selection;
6use serde::Deserialize;
7use workspace::Workspace;
8
9use crate::{motion::right, normal::normal_object, state::Mode, visual::visual_object, Vim};
10
11#[derive(Copy, Clone, Debug, PartialEq)]
12pub enum Object {
13 Word { ignore_punctuation: bool },
14 Sentence,
15 Quotes,
16 BackQuotes,
17 DoubleQuotes,
18 Parentheses,
19 SquareBrackets,
20 CurlyBrackets,
21 AngleBrackets,
22}
23
24#[derive(Clone, Deserialize, PartialEq)]
25#[serde(rename_all = "camelCase")]
26struct Word {
27 #[serde(default)]
28 ignore_punctuation: bool,
29}
30
31actions!(
32 vim,
33 [
34 Sentence,
35 Quotes,
36 BackQuotes,
37 DoubleQuotes,
38 Parentheses,
39 SquareBrackets,
40 CurlyBrackets,
41 AngleBrackets
42 ]
43);
44impl_actions!(vim, [Word]);
45
46pub fn init(cx: &mut AppContext) {
47 cx.add_action(
48 |_: &mut Workspace, &Word { ignore_punctuation }: &Word, cx: _| {
49 object(Object::Word { ignore_punctuation }, cx)
50 },
51 );
52 cx.add_action(|_: &mut Workspace, _: &Sentence, cx: _| object(Object::Sentence, cx));
53 cx.add_action(|_: &mut Workspace, _: &Quotes, cx: _| object(Object::Quotes, cx));
54 cx.add_action(|_: &mut Workspace, _: &BackQuotes, cx: _| object(Object::BackQuotes, cx));
55 cx.add_action(|_: &mut Workspace, _: &DoubleQuotes, cx: _| object(Object::DoubleQuotes, cx));
56 cx.add_action(|_: &mut Workspace, _: &Parentheses, cx: _| object(Object::Parentheses, cx));
57 cx.add_action(|_: &mut Workspace, _: &SquareBrackets, cx: _| {
58 object(Object::SquareBrackets, cx)
59 });
60 cx.add_action(|_: &mut Workspace, _: &CurlyBrackets, cx: _| object(Object::CurlyBrackets, cx));
61 cx.add_action(|_: &mut Workspace, _: &AngleBrackets, cx: _| object(Object::AngleBrackets, cx));
62}
63
64fn object(object: Object, cx: &mut WindowContext) {
65 match Vim::read(cx).state.mode {
66 Mode::Normal => normal_object(object, cx),
67 Mode::Visual { .. } => visual_object(object, cx),
68 Mode::Insert => {
69 // Shouldn't execute a text object in insert mode. Ignoring
70 }
71 }
72}
73
74impl Object {
75 pub fn range(
76 self,
77 map: &DisplaySnapshot,
78 relative_to: DisplayPoint,
79 around: bool,
80 ) -> Option<Range<DisplayPoint>> {
81 match self {
82 Object::Word { ignore_punctuation } => {
83 if around {
84 around_word(map, relative_to, ignore_punctuation)
85 } else {
86 in_word(map, relative_to, ignore_punctuation)
87 }
88 }
89 Object::Sentence => sentence(map, relative_to, around),
90 Object::Quotes => surrounding_markers(map, relative_to, around, false, '\'', '\''),
91 Object::BackQuotes => surrounding_markers(map, relative_to, around, false, '`', '`'),
92 Object::DoubleQuotes => surrounding_markers(map, relative_to, around, false, '"', '"'),
93 Object::Parentheses => surrounding_markers(map, relative_to, around, true, '(', ')'),
94 Object::SquareBrackets => surrounding_markers(map, relative_to, around, true, '[', ']'),
95 Object::CurlyBrackets => surrounding_markers(map, relative_to, around, true, '{', '}'),
96 Object::AngleBrackets => surrounding_markers(map, relative_to, around, true, '<', '>'),
97 }
98 }
99
100 pub fn expand_selection(
101 self,
102 map: &DisplaySnapshot,
103 selection: &mut Selection<DisplayPoint>,
104 around: bool,
105 ) -> bool {
106 if let Some(range) = self.range(map, selection.head(), around) {
107 selection.start = range.start;
108 selection.end = range.end;
109 true
110 } else {
111 false
112 }
113 }
114}
115
116/// Return a range that surrounds the word relative_to is in
117/// If relative_to is at the start of a word, return the word.
118/// If relative_to is between words, return the space between
119fn in_word(
120 map: &DisplaySnapshot,
121 relative_to: DisplayPoint,
122 ignore_punctuation: bool,
123) -> Option<Range<DisplayPoint>> {
124 // Use motion::right so that we consider the character under the cursor when looking for the start
125 let start = movement::find_preceding_boundary_in_line(
126 map,
127 right(map, relative_to, 1),
128 |left, right| {
129 char_kind(left).coerce_punctuation(ignore_punctuation)
130 != char_kind(right).coerce_punctuation(ignore_punctuation)
131 },
132 );
133 let end = movement::find_boundary_in_line(map, relative_to, |left, right| {
134 char_kind(left).coerce_punctuation(ignore_punctuation)
135 != char_kind(right).coerce_punctuation(ignore_punctuation)
136 });
137
138 Some(start..end)
139}
140
141/// Return a range that surrounds the word and following whitespace
142/// relative_to is in.
143/// If relative_to is at the start of a word, return the word and following whitespace.
144/// If relative_to is between words, return the whitespace back and the following word
145
146/// if in word
147/// delete that word
148/// if there is whitespace following the word, delete that as well
149/// otherwise, delete any preceding whitespace
150/// otherwise
151/// delete whitespace around cursor
152/// delete word following the cursor
153fn around_word(
154 map: &DisplaySnapshot,
155 relative_to: DisplayPoint,
156 ignore_punctuation: bool,
157) -> Option<Range<DisplayPoint>> {
158 let in_word = map
159 .chars_at(relative_to)
160 .next()
161 .map(|(c, _)| char_kind(c) != CharKind::Whitespace)
162 .unwrap_or(false);
163
164 if in_word {
165 around_containing_word(map, relative_to, ignore_punctuation)
166 } else {
167 around_next_word(map, relative_to, ignore_punctuation)
168 }
169}
170
171fn around_containing_word(
172 map: &DisplaySnapshot,
173 relative_to: DisplayPoint,
174 ignore_punctuation: bool,
175) -> Option<Range<DisplayPoint>> {
176 in_word(map, relative_to, ignore_punctuation)
177 .map(|range| expand_to_include_whitespace(map, range, true))
178}
179
180fn around_next_word(
181 map: &DisplaySnapshot,
182 relative_to: DisplayPoint,
183 ignore_punctuation: bool,
184) -> Option<Range<DisplayPoint>> {
185 // Get the start of the word
186 let start = movement::find_preceding_boundary_in_line(
187 map,
188 right(map, relative_to, 1),
189 |left, right| {
190 char_kind(left).coerce_punctuation(ignore_punctuation)
191 != char_kind(right).coerce_punctuation(ignore_punctuation)
192 },
193 );
194
195 let mut word_found = false;
196 let end = movement::find_boundary(map, relative_to, |left, right| {
197 let left_kind = char_kind(left).coerce_punctuation(ignore_punctuation);
198 let right_kind = char_kind(right).coerce_punctuation(ignore_punctuation);
199
200 let found = (word_found && left_kind != right_kind) || right == '\n' && left == '\n';
201
202 if right_kind != CharKind::Whitespace {
203 word_found = true;
204 }
205
206 found
207 });
208
209 Some(start..end)
210}
211
212fn sentence(
213 map: &DisplaySnapshot,
214 relative_to: DisplayPoint,
215 around: bool,
216) -> Option<Range<DisplayPoint>> {
217 let mut start = None;
218 let mut previous_end = relative_to;
219
220 let mut chars = map.chars_at(relative_to).peekable();
221
222 // Search backwards for the previous sentence end or current sentence start. Include the character under relative_to
223 for (char, point) in chars
224 .peek()
225 .cloned()
226 .into_iter()
227 .chain(map.reverse_chars_at(relative_to))
228 {
229 if is_sentence_end(map, point) {
230 break;
231 }
232
233 if is_possible_sentence_start(char) {
234 start = Some(point);
235 }
236
237 previous_end = point;
238 }
239
240 // Search forward for the end of the current sentence or if we are between sentences, the start of the next one
241 let mut end = relative_to;
242 for (char, point) in chars {
243 if start.is_none() && is_possible_sentence_start(char) {
244 if around {
245 start = Some(point);
246 continue;
247 } else {
248 end = point;
249 break;
250 }
251 }
252
253 end = point;
254 *end.column_mut() += char.len_utf8() as u32;
255 end = map.clip_point(end, Bias::Left);
256
257 if is_sentence_end(map, end) {
258 break;
259 }
260 }
261
262 let mut range = start.unwrap_or(previous_end)..end;
263 if around {
264 range = expand_to_include_whitespace(map, range, false);
265 }
266
267 Some(range)
268}
269
270fn is_possible_sentence_start(character: char) -> bool {
271 !character.is_whitespace() && character != '.'
272}
273
274const SENTENCE_END_PUNCTUATION: &[char] = &['.', '!', '?'];
275const SENTENCE_END_FILLERS: &[char] = &[')', ']', '"', '\''];
276const SENTENCE_END_WHITESPACE: &[char] = &[' ', '\t', '\n'];
277fn is_sentence_end(map: &DisplaySnapshot, point: DisplayPoint) -> bool {
278 let mut next_chars = map.chars_at(point).peekable();
279 if let Some((char, _)) = next_chars.next() {
280 // We are at a double newline. This position is a sentence end.
281 if char == '\n' && next_chars.peek().map(|(c, _)| c == &'\n').unwrap_or(false) {
282 return true;
283 }
284
285 // The next text is not a valid whitespace. This is not a sentence end
286 if !SENTENCE_END_WHITESPACE.contains(&char) {
287 return false;
288 }
289 }
290
291 for (char, _) in map.reverse_chars_at(point) {
292 if SENTENCE_END_PUNCTUATION.contains(&char) {
293 return true;
294 }
295
296 if !SENTENCE_END_FILLERS.contains(&char) {
297 return false;
298 }
299 }
300
301 return false;
302}
303
304/// Expands the passed range to include whitespace on one side or the other in a line. Attempts to add the
305/// whitespace to the end first and falls back to the start if there was none.
306fn expand_to_include_whitespace(
307 map: &DisplaySnapshot,
308 mut range: Range<DisplayPoint>,
309 stop_at_newline: bool,
310) -> Range<DisplayPoint> {
311 let mut whitespace_included = false;
312
313 let mut chars = map.chars_at(range.end).peekable();
314 while let Some((char, point)) = chars.next() {
315 if char == '\n' && stop_at_newline {
316 break;
317 }
318
319 if char.is_whitespace() {
320 // Set end to the next display_point or the character position after the current display_point
321 range.end = chars.peek().map(|(_, point)| *point).unwrap_or_else(|| {
322 let mut end = point;
323 *end.column_mut() += char.len_utf8() as u32;
324 map.clip_point(end, Bias::Left)
325 });
326
327 if char != '\n' {
328 whitespace_included = true;
329 }
330 } else {
331 // Found non whitespace. Quit out.
332 break;
333 }
334 }
335
336 if !whitespace_included {
337 for (char, point) in map.reverse_chars_at(range.start) {
338 if char == '\n' && stop_at_newline {
339 break;
340 }
341
342 if !char.is_whitespace() {
343 break;
344 }
345
346 range.start = point;
347 }
348 }
349
350 range
351}
352
353fn surrounding_markers(
354 map: &DisplaySnapshot,
355 relative_to: DisplayPoint,
356 around: bool,
357 search_across_lines: bool,
358 start_marker: char,
359 end_marker: char,
360) -> Option<Range<DisplayPoint>> {
361 let mut matched_ends = 0;
362 let mut start = None;
363 for (char, mut point) in map.reverse_chars_at(relative_to) {
364 if char == start_marker {
365 if matched_ends > 0 {
366 matched_ends -= 1;
367 } else {
368 if around {
369 start = Some(point)
370 } else {
371 *point.column_mut() += char.len_utf8() as u32;
372 start = Some(point);
373 }
374 break;
375 }
376 } else if char == end_marker {
377 matched_ends += 1;
378 } else if char == '\n' && !search_across_lines {
379 break;
380 }
381 }
382
383 let mut matched_starts = 0;
384 let mut end = None;
385 for (char, mut point) in map.chars_at(relative_to) {
386 if char == end_marker {
387 if start.is_none() {
388 break;
389 }
390
391 if matched_starts > 0 {
392 matched_starts -= 1;
393 } else {
394 if around {
395 *point.column_mut() += char.len_utf8() as u32;
396 end = Some(point);
397 } else {
398 end = Some(point);
399 }
400
401 break;
402 }
403 }
404
405 if char == start_marker {
406 if start.is_none() {
407 if around {
408 start = Some(point);
409 } else {
410 *point.column_mut() += char.len_utf8() as u32;
411 start = Some(point);
412 }
413 } else {
414 matched_starts += 1;
415 }
416 }
417
418 if char == '\n' && !search_across_lines {
419 break;
420 }
421 }
422
423 if let (Some(start), Some(end)) = (start, end) {
424 Some(start..end)
425 } else {
426 None
427 }
428}
429
430#[cfg(test)]
431mod test {
432 use indoc::indoc;
433
434 use crate::test::{ExemptionFeatures, NeovimBackedTestContext};
435
436 const WORD_LOCATIONS: &'static str = indoc! {"
437 The quick ˇbrowˇnˇ•••
438 fox ˇjuˇmpsˇ over
439 the lazy dogˇ••
440 ˇ
441 ˇ
442 ˇ
443 Thˇeˇ-ˇquˇickˇ ˇbrownˇ•
444 ˇ••
445 ˇ••
446 ˇ fox-jumpˇs over
447 the lazy dogˇ•
448 ˇ
449 "
450 };
451
452 #[gpui::test]
453 async fn test_change_word_object(cx: &mut gpui::TestAppContext) {
454 let mut cx = NeovimBackedTestContext::new(cx).await;
455
456 cx.assert_binding_matches_all(["c", "i", "w"], WORD_LOCATIONS)
457 .await;
458 cx.assert_binding_matches_all(["c", "i", "shift-w"], WORD_LOCATIONS)
459 .await;
460 cx.assert_binding_matches_all(["c", "a", "w"], WORD_LOCATIONS)
461 .await;
462 cx.assert_binding_matches_all(["c", "a", "shift-w"], WORD_LOCATIONS)
463 .await;
464 }
465
466 #[gpui::test]
467 async fn test_delete_word_object(cx: &mut gpui::TestAppContext) {
468 let mut cx = NeovimBackedTestContext::new(cx).await;
469
470 cx.assert_binding_matches_all(["d", "i", "w"], WORD_LOCATIONS)
471 .await;
472 cx.assert_binding_matches_all(["d", "i", "shift-w"], WORD_LOCATIONS)
473 .await;
474 cx.assert_binding_matches_all(["d", "a", "w"], WORD_LOCATIONS)
475 .await;
476 cx.assert_binding_matches_all(["d", "a", "shift-w"], WORD_LOCATIONS)
477 .await;
478 }
479
480 #[gpui::test]
481 async fn test_visual_word_object(cx: &mut gpui::TestAppContext) {
482 let mut cx = NeovimBackedTestContext::new(cx).await;
483
484 cx.assert_binding_matches_all(["v", "i", "w"], WORD_LOCATIONS)
485 .await;
486 cx.assert_binding_matches_all_exempted(
487 ["v", "h", "i", "w"],
488 WORD_LOCATIONS,
489 ExemptionFeatures::NonEmptyVisualTextObjects,
490 )
491 .await;
492 cx.assert_binding_matches_all_exempted(
493 ["v", "l", "i", "w"],
494 WORD_LOCATIONS,
495 ExemptionFeatures::NonEmptyVisualTextObjects,
496 )
497 .await;
498 cx.assert_binding_matches_all(["v", "i", "shift-w"], WORD_LOCATIONS)
499 .await;
500
501 cx.assert_binding_matches_all_exempted(
502 ["v", "i", "h", "shift-w"],
503 WORD_LOCATIONS,
504 ExemptionFeatures::NonEmptyVisualTextObjects,
505 )
506 .await;
507 cx.assert_binding_matches_all_exempted(
508 ["v", "i", "l", "shift-w"],
509 WORD_LOCATIONS,
510 ExemptionFeatures::NonEmptyVisualTextObjects,
511 )
512 .await;
513
514 cx.assert_binding_matches_all_exempted(
515 ["v", "a", "w"],
516 WORD_LOCATIONS,
517 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
518 )
519 .await;
520 cx.assert_binding_matches_all_exempted(
521 ["v", "a", "shift-w"],
522 WORD_LOCATIONS,
523 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
524 )
525 .await;
526 }
527
528 const SENTENCE_EXAMPLES: &[&'static str] = &[
529 "ˇThe quick ˇbrownˇ?ˇ ˇFox Jˇumpsˇ!ˇ Ovˇer theˇ lazyˇ.",
530 indoc! {"
531 ˇThe quick ˇbrownˇ
532 fox jumps over
533 the lazy doˇgˇ.ˇ ˇThe quick ˇ
534 brown fox jumps over
535 "},
536 indoc! {"
537 The quick brown fox jumps.
538 Over the lazy dog
539 ˇ
540 ˇ
541 ˇ fox-jumpˇs over
542 the lazy dog.ˇ
543 ˇ
544 "},
545 r#"ˇThe ˇquick brownˇ.)ˇ]ˇ'ˇ" Brown ˇfox jumpsˇ.ˇ "#,
546 ];
547
548 #[gpui::test]
549 async fn test_change_sentence_object(cx: &mut gpui::TestAppContext) {
550 let mut cx = NeovimBackedTestContext::new(cx)
551 .await
552 .binding(["c", "i", "s"]);
553 cx.add_initial_state_exemptions(
554 "The quick brown fox jumps.\nOver the lazy dog\nˇ\nˇ\n fox-jumps over\nthe lazy dog.\n\n",
555 ExemptionFeatures::SentenceOnEmptyLines);
556 cx.add_initial_state_exemptions(
557 "The quick brown fox jumps.\nOver the lazy dog\n\n\nˇ foxˇ-ˇjumpˇs over\nthe lazy dog.\n\n",
558 ExemptionFeatures::SentenceAtStartOfLineWithWhitespace);
559 cx.add_initial_state_exemptions(
560 "The quick brown fox jumps.\nOver the lazy dog\n\n\n fox-jumps over\nthe lazy dog.ˇ\nˇ\n",
561 ExemptionFeatures::SentenceAfterPunctuationAtEndOfFile);
562 for sentence_example in SENTENCE_EXAMPLES {
563 cx.assert_all(sentence_example).await;
564 }
565
566 let mut cx = cx.binding(["c", "a", "s"]);
567 cx.add_initial_state_exemptions(
568 "The quick brown?ˇ Fox Jumps! Over the lazy.",
569 ExemptionFeatures::IncorrectLandingPosition,
570 );
571 cx.add_initial_state_exemptions(
572 "The quick brown.)]\'\" Brown fox jumps.ˇ ",
573 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
574 );
575
576 for sentence_example in SENTENCE_EXAMPLES {
577 cx.assert_all(sentence_example).await;
578 }
579 }
580
581 #[gpui::test]
582 async fn test_delete_sentence_object(cx: &mut gpui::TestAppContext) {
583 let mut cx = NeovimBackedTestContext::new(cx)
584 .await
585 .binding(["d", "i", "s"]);
586 cx.add_initial_state_exemptions(
587 "The quick brown fox jumps.\nOver the lazy dog\nˇ\nˇ\n fox-jumps over\nthe lazy dog.\n\n",
588 ExemptionFeatures::SentenceOnEmptyLines);
589 cx.add_initial_state_exemptions(
590 "The quick brown fox jumps.\nOver the lazy dog\n\n\nˇ foxˇ-ˇjumpˇs over\nthe lazy dog.\n\n",
591 ExemptionFeatures::SentenceAtStartOfLineWithWhitespace);
592 cx.add_initial_state_exemptions(
593 "The quick brown fox jumps.\nOver the lazy dog\n\n\n fox-jumps over\nthe lazy dog.ˇ\nˇ\n",
594 ExemptionFeatures::SentenceAfterPunctuationAtEndOfFile);
595
596 for sentence_example in SENTENCE_EXAMPLES {
597 cx.assert_all(sentence_example).await;
598 }
599
600 let mut cx = cx.binding(["d", "a", "s"]);
601 cx.add_initial_state_exemptions(
602 "The quick brown?ˇ Fox Jumps! Over the lazy.",
603 ExemptionFeatures::IncorrectLandingPosition,
604 );
605 cx.add_initial_state_exemptions(
606 "The quick brown.)]\'\" Brown fox jumps.ˇ ",
607 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
608 );
609
610 for sentence_example in SENTENCE_EXAMPLES {
611 cx.assert_all(sentence_example).await;
612 }
613 }
614
615 #[gpui::test]
616 async fn test_visual_sentence_object(cx: &mut gpui::TestAppContext) {
617 let mut cx = NeovimBackedTestContext::new(cx)
618 .await
619 .binding(["v", "i", "s"]);
620 for sentence_example in SENTENCE_EXAMPLES {
621 cx.assert_all_exempted(sentence_example, ExemptionFeatures::SentenceOnEmptyLines)
622 .await;
623 }
624
625 let mut cx = cx.binding(["v", "a", "s"]);
626 for sentence_example in SENTENCE_EXAMPLES {
627 cx.assert_all_exempted(
628 sentence_example,
629 ExemptionFeatures::AroundSentenceStartingBetweenIncludesWrongWhitespace,
630 )
631 .await;
632 }
633 }
634
635 // Test string with "`" for opening surrounders and "'" for closing surrounders
636 const SURROUNDING_MARKER_STRING: &str = indoc! {"
637 ˇTh'ˇe ˇ`ˇ'ˇquˇi`ˇck broˇ'wn`
638 'ˇfox juˇmps ovˇ`ˇer
639 the ˇlazy dˇ'ˇoˇ`ˇg"};
640
641 const SURROUNDING_OBJECTS: &[(char, char)] = &[
642 ('\'', '\''), // Quote
643 ('`', '`'), // Back Quote
644 ('"', '"'), // Double Quote
645 ('(', ')'), // Parentheses
646 ('[', ']'), // SquareBrackets
647 ('{', '}'), // CurlyBrackets
648 ('<', '>'), // AngleBrackets
649 ];
650
651 #[gpui::test]
652 async fn test_change_surrounding_character_objects(cx: &mut gpui::TestAppContext) {
653 let mut cx = NeovimBackedTestContext::new(cx).await;
654
655 for (start, end) in SURROUNDING_OBJECTS {
656 if ((start == &'\'' || start == &'`' || start == &'"')
657 && !ExemptionFeatures::QuotesSeekForward.supported())
658 || (start == &'<' && !ExemptionFeatures::AngleBracketsFreezeNeovim.supported())
659 {
660 continue;
661 }
662
663 let marked_string = SURROUNDING_MARKER_STRING
664 .replace('`', &start.to_string())
665 .replace('\'', &end.to_string());
666
667 cx.assert_binding_matches_all(["c", "i", &start.to_string()], &marked_string)
668 .await;
669 cx.assert_binding_matches_all(["c", "i", &end.to_string()], &marked_string)
670 .await;
671 cx.assert_binding_matches_all(["c", "a", &start.to_string()], &marked_string)
672 .await;
673 cx.assert_binding_matches_all(["c", "a", &end.to_string()], &marked_string)
674 .await;
675 }
676 }
677
678 #[gpui::test]
679 async fn test_delete_surrounding_character_objects(cx: &mut gpui::TestAppContext) {
680 let mut cx = NeovimBackedTestContext::new(cx).await;
681
682 for (start, end) in SURROUNDING_OBJECTS {
683 if ((start == &'\'' || start == &'`' || start == &'"')
684 && !ExemptionFeatures::QuotesSeekForward.supported())
685 || (start == &'<' && !ExemptionFeatures::AngleBracketsFreezeNeovim.supported())
686 {
687 continue;
688 }
689 let marked_string = SURROUNDING_MARKER_STRING
690 .replace('`', &start.to_string())
691 .replace('\'', &end.to_string());
692
693 cx.assert_binding_matches_all(["d", "i", &start.to_string()], &marked_string)
694 .await;
695 cx.assert_binding_matches_all(["d", "i", &end.to_string()], &marked_string)
696 .await;
697 cx.assert_binding_matches_all(["d", "a", &start.to_string()], &marked_string)
698 .await;
699 cx.assert_binding_matches_all(["d", "a", &end.to_string()], &marked_string)
700 .await;
701 }
702 }
703}