@@ -413,7 +413,9 @@ fn byte_index_of(s: &str, utf_16_index: usize) -> usize {
413413/// Translate from CodeMirror to CodeDocBlocks.
414414fn code_mirror_to_code_doc_blocks ( code_mirror : & CodeMirror ) -> Vec < CodeDocBlock > {
415415 let doc_blocks = & code_mirror. doc_blocks ;
416- // Translate between UTF-16 code units (the `from` and `to` provided by CodeMirror) and byte indexes (which Rust uses). Keep track of the current byte index/UTF-16 index; we always move forward from that location.
416+ // Translate between UTF-16 code units (the `from` and `to` provided by
417+ // CodeMirror) and byte indexes (which Rust uses). Keep track of the current
418+ // byte index/UTF-16 index; we always move forward from that location.
417419 let mut byte_index: usize = 0 ;
418420 let mut utf16_index: usize = 0 ;
419421 let mut code_doc_block_arr: Vec < CodeDocBlock > = Vec :: new ( ) ;
@@ -1060,15 +1062,17 @@ pub fn diff_code_mirror_doc_blocks(
10601062 & mut change_specs,
10611063 ) ;
10621064
1063- // If two doc blocks immediately follow each other: `# foo\n # bar\n`, for example,
1064- // and a line is inserted before both, then a problem occurs when applying the change:
1065- // applying the change to the first block sets its `from` value to the `from` value
1066- // for the second block. This violates a doc blocks invariant -- each doc block
1067- // must have a unique `from` value; therefore, these two doc blocks can no longer be
1068- // distinguished, making it impossible to apply the change to the second doc block.
1069- // More generally, this can occur with an insert before a series of blocks which
1070- // immediately follow each other. Therefore, look for sequences of updates where `from_new` of a previous entry == `from` of the current
1071- // entry and swap these sequences.
1065+ // If two doc blocks immediately follow each other: `# foo\n # bar\n`, for
1066+ // example, and a line is inserted before both, then a problem occurs when
1067+ // applying the change: applying the change to the first block sets its
1068+ // `from` value to the `from` value for the second block. This violates a
1069+ // doc blocks invariant -- each doc block must have a unique `from` value;
1070+ // therefore, these two doc blocks can no longer be distinguished, making it
1071+ // impossible to apply the change to the second doc block. More generally,
1072+ // this can occur with an insert before a series of blocks which immediately
1073+ // follow each other. Therefore, look for sequences of updates where
1074+ // `from_new` of a previous entry == `from` of the current entry and swap
1075+ // these sequences.
10721076 let mut immediate_sequence_start_index: Option < usize > = None ;
10731077 for index in 1 ..change_specs. len ( ) {
10741078 if let CodeMirrorDocBlockTransaction :: Update ( prev_update) = & change_specs[ index - 1 ]
0 commit comments