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 #[gpui::test]
452 async fn test_change_word_object(cx: &mut gpui::TestAppContext) {
453 let mut cx = NeovimBackedTestContext::new(cx).await;
454
455 cx.assert_binding_matches_all(["c", "i", "w"], WORD_LOCATIONS)
456 .await;
457 cx.assert_binding_matches_all(["c", "i", "shift-w"], WORD_LOCATIONS)
458 .await;
459 cx.assert_binding_matches_all(["c", "a", "w"], WORD_LOCATIONS)
460 .await;
461 cx.assert_binding_matches_all(["c", "a", "shift-w"], WORD_LOCATIONS)
462 .await;
463 }
464
465 #[gpui::test]
466 async fn test_delete_word_object(cx: &mut gpui::TestAppContext) {
467 let mut cx = NeovimBackedTestContext::new(cx).await;
468
469 cx.assert_binding_matches_all(["d", "i", "w"], WORD_LOCATIONS)
470 .await;
471 cx.assert_binding_matches_all(["d", "i", "shift-w"], WORD_LOCATIONS)
472 .await;
473 cx.assert_binding_matches_all(["d", "a", "w"], WORD_LOCATIONS)
474 .await;
475 cx.assert_binding_matches_all(["d", "a", "shift-w"], WORD_LOCATIONS)
476 .await;
477 }
478
479 #[gpui::test]
480 async fn test_visual_word_object(cx: &mut gpui::TestAppContext) {
481 let mut cx = NeovimBackedTestContext::new(cx).await;
482
483 cx.assert_binding_matches_all(["v", "i", "w"], WORD_LOCATIONS)
484 .await;
485 cx.assert_binding_matches_all_exempted(
486 ["v", "h", "i", "w"],
487 WORD_LOCATIONS,
488 ExemptionFeatures::NonEmptyVisualTextObjects,
489 )
490 .await;
491 cx.assert_binding_matches_all_exempted(
492 ["v", "l", "i", "w"],
493 WORD_LOCATIONS,
494 ExemptionFeatures::NonEmptyVisualTextObjects,
495 )
496 .await;
497 cx.assert_binding_matches_all(["v", "i", "shift-w"], WORD_LOCATIONS)
498 .await;
499
500 cx.assert_binding_matches_all_exempted(
501 ["v", "i", "h", "shift-w"],
502 WORD_LOCATIONS,
503 ExemptionFeatures::NonEmptyVisualTextObjects,
504 )
505 .await;
506 cx.assert_binding_matches_all_exempted(
507 ["v", "i", "l", "shift-w"],
508 WORD_LOCATIONS,
509 ExemptionFeatures::NonEmptyVisualTextObjects,
510 )
511 .await;
512
513 cx.assert_binding_matches_all_exempted(
514 ["v", "a", "w"],
515 WORD_LOCATIONS,
516 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
517 )
518 .await;
519 cx.assert_binding_matches_all_exempted(
520 ["v", "a", "shift-w"],
521 WORD_LOCATIONS,
522 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
523 )
524 .await;
525 }
526
527 const SENTENCE_EXAMPLES: &[&'static str] = &[
528 "ˇThe quick ˇbrownˇ?ˇ ˇFox Jˇumpsˇ!ˇ Ovˇer theˇ lazyˇ.",
529 indoc! {"
530 ˇThe quick ˇbrownˇ
531 fox jumps over
532 the lazy doˇgˇ.ˇ ˇThe quick ˇ
533 brown fox jumps over
534 "},
535 indoc! {"
536 The quick brown fox jumps.
537 Over the lazy dog
538 ˇ
539 ˇ
540 ˇ fox-jumpˇs over
541 the lazy dog.ˇ
542 ˇ
543 "},
544 r#"ˇThe ˇquick brownˇ.)ˇ]ˇ'ˇ" Brown ˇfox jumpsˇ.ˇ "#,
545 ];
546
547 #[gpui::test]
548 async fn test_change_sentence_object(cx: &mut gpui::TestAppContext) {
549 let mut cx = NeovimBackedTestContext::new(cx)
550 .await
551 .binding(["c", "i", "s"]);
552 cx.add_initial_state_exemptions(
553 "The quick brown fox jumps.\nOver the lazy dog\nˇ\nˇ\n fox-jumps over\nthe lazy dog.\n\n",
554 ExemptionFeatures::SentenceOnEmptyLines);
555 cx.add_initial_state_exemptions(
556 "The quick brown fox jumps.\nOver the lazy dog\n\n\nˇ foxˇ-ˇjumpˇs over\nthe lazy dog.\n\n",
557 ExemptionFeatures::SentenceAtStartOfLineWithWhitespace);
558 cx.add_initial_state_exemptions(
559 "The quick brown fox jumps.\nOver the lazy dog\n\n\n fox-jumps over\nthe lazy dog.ˇ\nˇ\n",
560 ExemptionFeatures::SentenceAfterPunctuationAtEndOfFile);
561 for sentence_example in SENTENCE_EXAMPLES {
562 cx.assert_all(sentence_example).await;
563 }
564
565 let mut cx = cx.binding(["c", "a", "s"]);
566 cx.add_initial_state_exemptions(
567 "The quick brown?ˇ Fox Jumps! Over the lazy.",
568 ExemptionFeatures::IncorrectLandingPosition,
569 );
570 cx.add_initial_state_exemptions(
571 "The quick brown.)]\'\" Brown fox jumps.ˇ ",
572 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
573 );
574
575 for sentence_example in SENTENCE_EXAMPLES {
576 cx.assert_all(sentence_example).await;
577 }
578 }
579
580 #[gpui::test]
581 async fn test_delete_sentence_object(cx: &mut gpui::TestAppContext) {
582 let mut cx = NeovimBackedTestContext::new(cx)
583 .await
584 .binding(["d", "i", "s"]);
585 cx.add_initial_state_exemptions(
586 "The quick brown fox jumps.\nOver the lazy dog\nˇ\nˇ\n fox-jumps over\nthe lazy dog.\n\n",
587 ExemptionFeatures::SentenceOnEmptyLines);
588 cx.add_initial_state_exemptions(
589 "The quick brown fox jumps.\nOver the lazy dog\n\n\nˇ foxˇ-ˇjumpˇs over\nthe lazy dog.\n\n",
590 ExemptionFeatures::SentenceAtStartOfLineWithWhitespace);
591 cx.add_initial_state_exemptions(
592 "The quick brown fox jumps.\nOver the lazy dog\n\n\n fox-jumps over\nthe lazy dog.ˇ\nˇ\n",
593 ExemptionFeatures::SentenceAfterPunctuationAtEndOfFile);
594
595 for sentence_example in SENTENCE_EXAMPLES {
596 cx.assert_all(sentence_example).await;
597 }
598
599 let mut cx = cx.binding(["d", "a", "s"]);
600 cx.add_initial_state_exemptions(
601 "The quick brown?ˇ Fox Jumps! Over the lazy.",
602 ExemptionFeatures::IncorrectLandingPosition,
603 );
604 cx.add_initial_state_exemptions(
605 "The quick brown.)]\'\" Brown fox jumps.ˇ ",
606 ExemptionFeatures::AroundObjectLeavesWhitespaceAtEndOfLine,
607 );
608
609 for sentence_example in SENTENCE_EXAMPLES {
610 cx.assert_all(sentence_example).await;
611 }
612 }
613
614 #[gpui::test]
615 async fn test_visual_sentence_object(cx: &mut gpui::TestAppContext) {
616 let mut cx = NeovimBackedTestContext::new(cx)
617 .await
618 .binding(["v", "i", "s"]);
619 for sentence_example in SENTENCE_EXAMPLES {
620 cx.assert_all_exempted(sentence_example, ExemptionFeatures::SentenceOnEmptyLines)
621 .await;
622 }
623
624 let mut cx = cx.binding(["v", "a", "s"]);
625 for sentence_example in SENTENCE_EXAMPLES {
626 cx.assert_all_exempted(
627 sentence_example,
628 ExemptionFeatures::AroundSentenceStartingBetweenIncludesWrongWhitespace,
629 )
630 .await;
631 }
632 }
633
634 // Test string with "`" for opening surrounders and "'" for closing surrounders
635 const SURROUNDING_MARKER_STRING: &str = indoc! {"
636 ˇTh'ˇe ˇ`ˇ'ˇquˇi`ˇck broˇ'wn`
637 'ˇfox juˇmps ovˇ`ˇer
638 the ˇlazy dˇ'ˇoˇ`ˇg"};
639
640 const SURROUNDING_OBJECTS: &[(char, char)] = &[
641 ('\'', '\''), // Quote
642 ('`', '`'), // Back Quote
643 ('"', '"'), // Double Quote
644 ('(', ')'), // Parentheses
645 ('[', ']'), // SquareBrackets
646 ('{', '}'), // CurlyBrackets
647 ('<', '>'), // AngleBrackets
648 ];
649
650 #[gpui::test]
651 async fn test_change_surrounding_character_objects(cx: &mut gpui::TestAppContext) {
652 let mut cx = NeovimBackedTestContext::new(cx).await;
653
654 for (start, end) in SURROUNDING_OBJECTS {
655 if ((start == &'\'' || start == &'`' || start == &'"')
656 && !ExemptionFeatures::QuotesSeekForward.supported())
657 || (start == &'<' && !ExemptionFeatures::AngleBracketsFreezeNeovim.supported())
658 {
659 continue;
660 }
661
662 let marked_string = SURROUNDING_MARKER_STRING
663 .replace('`', &start.to_string())
664 .replace('\'', &end.to_string());
665
666 cx.assert_binding_matches_all(["c", "i", &start.to_string()], &marked_string)
667 .await;
668 cx.assert_binding_matches_all(["c", "i", &end.to_string()], &marked_string)
669 .await;
670 cx.assert_binding_matches_all(["c", "a", &start.to_string()], &marked_string)
671 .await;
672 cx.assert_binding_matches_all(["c", "a", &end.to_string()], &marked_string)
673 .await;
674 }
675 }
676
677 #[gpui::test]
678 async fn test_delete_surrounding_character_objects(cx: &mut gpui::TestAppContext) {
679 let mut cx = NeovimBackedTestContext::new(cx).await;
680
681 for (start, end) in SURROUNDING_OBJECTS {
682 if ((start == &'\'' || start == &'`' || start == &'"')
683 && !ExemptionFeatures::QuotesSeekForward.supported())
684 || (start == &'<' && !ExemptionFeatures::AngleBracketsFreezeNeovim.supported())
685 {
686 continue;
687 }
688 let marked_string = SURROUNDING_MARKER_STRING
689 .replace('`', &start.to_string())
690 .replace('\'', &end.to_string());
691
692 cx.assert_binding_matches_all(["d", "i", &start.to_string()], &marked_string)
693 .await;
694 cx.assert_binding_matches_all(["d", "i", &end.to_string()], &marked_string)
695 .await;
696 cx.assert_binding_matches_all(["d", "a", &start.to_string()], &marked_string)
697 .await;
698 cx.assert_binding_matches_all(["d", "a", &end.to_string()], &marked_string)
699 .await;
700 }
701 }
702}