From acd51cb361720458615bd1ceb909b0f4461328df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Fri, 16 Nov 2018 12:16:20 +0100 Subject: cargo format --- crates/ra_editor/src/line_index.rs | 112 ++++++++++++++++++++++++++++++++----- 1 file changed, 98 insertions(+), 14 deletions(-) (limited to 'crates/ra_editor/src') diff --git a/crates/ra_editor/src/line_index.rs b/crates/ra_editor/src/line_index.rs index 26b309b78..aab7e4081 100644 --- a/crates/ra_editor/src/line_index.rs +++ b/crates/ra_editor/src/line_index.rs @@ -126,23 +126,107 @@ impl LineIndex { fn test_line_index() { let text = "hello\nworld"; let index = LineIndex::new(text); - assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); - assert_eq!(index.line_col(1.into()), LineCol { line: 0, col_utf16: 1 }); - assert_eq!(index.line_col(5.into()), LineCol { line: 0, col_utf16: 5 }); - assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 0 }); - assert_eq!(index.line_col(7.into()), LineCol { line: 1, col_utf16: 1 }); - assert_eq!(index.line_col(8.into()), LineCol { line: 1, col_utf16: 2 }); - assert_eq!(index.line_col(10.into()), LineCol { line: 1, col_utf16: 4 }); - assert_eq!(index.line_col(11.into()), LineCol { line: 1, col_utf16: 5 }); - assert_eq!(index.line_col(12.into()), LineCol { line: 1, col_utf16: 6 }); + assert_eq!( + index.line_col(0.into()), + LineCol { + line: 0, + col_utf16: 0 + } + ); + assert_eq!( + index.line_col(1.into()), + LineCol { + line: 0, + col_utf16: 1 + } + ); + assert_eq!( + index.line_col(5.into()), + LineCol { + line: 0, + col_utf16: 5 + } + ); + assert_eq!( + index.line_col(6.into()), + LineCol { + line: 1, + col_utf16: 0 + } + ); + assert_eq!( + index.line_col(7.into()), + LineCol { + line: 1, + col_utf16: 1 + } + ); + assert_eq!( + index.line_col(8.into()), + LineCol { + line: 1, + col_utf16: 2 + } + ); + assert_eq!( + index.line_col(10.into()), + LineCol { + line: 1, + col_utf16: 4 + } + ); + assert_eq!( + index.line_col(11.into()), + LineCol { + line: 1, + col_utf16: 5 + } + ); + assert_eq!( + index.line_col(12.into()), + LineCol { + line: 1, + col_utf16: 6 + } + ); let text = "\nhello\nworld"; let index = LineIndex::new(text); - assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); - assert_eq!(index.line_col(1.into()), LineCol { line: 1, col_utf16: 0 }); - assert_eq!(index.line_col(2.into()), LineCol { line: 1, col_utf16: 1 }); - assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 5 }); - assert_eq!(index.line_col(7.into()), LineCol { line: 2, col_utf16: 0 }); + assert_eq!( + index.line_col(0.into()), + LineCol { + line: 0, + col_utf16: 0 + } + ); + assert_eq!( + index.line_col(1.into()), + LineCol { + line: 1, + col_utf16: 0 + } + ); + assert_eq!( + index.line_col(2.into()), + LineCol { + line: 1, + col_utf16: 1 + } + ); + assert_eq!( + index.line_col(6.into()), + LineCol { + line: 1, + col_utf16: 5 + } + ); + assert_eq!( + index.line_col(7.into()), + LineCol { + line: 2, + col_utf16: 0 + } + ); } #[cfg(test)] -- cgit v1.2.3