diff options
author | Adolfo OchagavĂa <[email protected]> | 2018-11-16 11:16:20 +0000 |
---|---|---|
committer | Adolfo OchagavĂa <[email protected]> | 2018-11-16 11:16:20 +0000 |
commit | acd51cb361720458615bd1ceb909b0f4461328df (patch) | |
tree | 00706a794c4ed567090d2e24403ee9729c8557ae /crates/ra_editor | |
parent | bccbee5ba3eea3decaf3d00a5dc09dd6cbc632f1 (diff) |
cargo format
Diffstat (limited to 'crates/ra_editor')
-rw-r--r-- | crates/ra_editor/src/line_index.rs | 112 |
1 files changed, 98 insertions, 14 deletions
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 { | |||
126 | fn test_line_index() { | 126 | fn test_line_index() { |
127 | let text = "hello\nworld"; | 127 | let text = "hello\nworld"; |
128 | let index = LineIndex::new(text); | 128 | let index = LineIndex::new(text); |
129 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | 129 | assert_eq!( |
130 | assert_eq!(index.line_col(1.into()), LineCol { line: 0, col_utf16: 1 }); | 130 | index.line_col(0.into()), |
131 | assert_eq!(index.line_col(5.into()), LineCol { line: 0, col_utf16: 5 }); | 131 | LineCol { |
132 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 0 }); | 132 | line: 0, |
133 | assert_eq!(index.line_col(7.into()), LineCol { line: 1, col_utf16: 1 }); | 133 | col_utf16: 0 |
134 | assert_eq!(index.line_col(8.into()), LineCol { line: 1, col_utf16: 2 }); | 134 | } |
135 | assert_eq!(index.line_col(10.into()), LineCol { line: 1, col_utf16: 4 }); | 135 | ); |
136 | assert_eq!(index.line_col(11.into()), LineCol { line: 1, col_utf16: 5 }); | 136 | assert_eq!( |
137 | assert_eq!(index.line_col(12.into()), LineCol { line: 1, col_utf16: 6 }); | 137 | index.line_col(1.into()), |
138 | LineCol { | ||
139 | line: 0, | ||
140 | col_utf16: 1 | ||
141 | } | ||
142 | ); | ||
143 | assert_eq!( | ||
144 | index.line_col(5.into()), | ||
145 | LineCol { | ||
146 | line: 0, | ||
147 | col_utf16: 5 | ||
148 | } | ||
149 | ); | ||
150 | assert_eq!( | ||
151 | index.line_col(6.into()), | ||
152 | LineCol { | ||
153 | line: 1, | ||
154 | col_utf16: 0 | ||
155 | } | ||
156 | ); | ||
157 | assert_eq!( | ||
158 | index.line_col(7.into()), | ||
159 | LineCol { | ||
160 | line: 1, | ||
161 | col_utf16: 1 | ||
162 | } | ||
163 | ); | ||
164 | assert_eq!( | ||
165 | index.line_col(8.into()), | ||
166 | LineCol { | ||
167 | line: 1, | ||
168 | col_utf16: 2 | ||
169 | } | ||
170 | ); | ||
171 | assert_eq!( | ||
172 | index.line_col(10.into()), | ||
173 | LineCol { | ||
174 | line: 1, | ||
175 | col_utf16: 4 | ||
176 | } | ||
177 | ); | ||
178 | assert_eq!( | ||
179 | index.line_col(11.into()), | ||
180 | LineCol { | ||
181 | line: 1, | ||
182 | col_utf16: 5 | ||
183 | } | ||
184 | ); | ||
185 | assert_eq!( | ||
186 | index.line_col(12.into()), | ||
187 | LineCol { | ||
188 | line: 1, | ||
189 | col_utf16: 6 | ||
190 | } | ||
191 | ); | ||
138 | 192 | ||
139 | let text = "\nhello\nworld"; | 193 | let text = "\nhello\nworld"; |
140 | let index = LineIndex::new(text); | 194 | let index = LineIndex::new(text); |
141 | assert_eq!(index.line_col(0.into()), LineCol { line: 0, col_utf16: 0 }); | 195 | assert_eq!( |
142 | assert_eq!(index.line_col(1.into()), LineCol { line: 1, col_utf16: 0 }); | 196 | index.line_col(0.into()), |
143 | assert_eq!(index.line_col(2.into()), LineCol { line: 1, col_utf16: 1 }); | 197 | LineCol { |
144 | assert_eq!(index.line_col(6.into()), LineCol { line: 1, col_utf16: 5 }); | 198 | line: 0, |
145 | assert_eq!(index.line_col(7.into()), LineCol { line: 2, col_utf16: 0 }); | 199 | col_utf16: 0 |
200 | } | ||
201 | ); | ||
202 | assert_eq!( | ||
203 | index.line_col(1.into()), | ||
204 | LineCol { | ||
205 | line: 1, | ||
206 | col_utf16: 0 | ||
207 | } | ||
208 | ); | ||
209 | assert_eq!( | ||
210 | index.line_col(2.into()), | ||
211 | LineCol { | ||
212 | line: 1, | ||
213 | col_utf16: 1 | ||
214 | } | ||
215 | ); | ||
216 | assert_eq!( | ||
217 | index.line_col(6.into()), | ||
218 | LineCol { | ||
219 | line: 1, | ||
220 | col_utf16: 5 | ||
221 | } | ||
222 | ); | ||
223 | assert_eq!( | ||
224 | index.line_col(7.into()), | ||
225 | LineCol { | ||
226 | line: 2, | ||
227 | col_utf16: 0 | ||
228 | } | ||
229 | ); | ||
146 | } | 230 | } |
147 | 231 | ||
148 | #[cfg(test)] | 232 | #[cfg(test)] |