Skip to content

Commit f71c330

Browse files
committed
Ruby: address review comment
1 parent 6fd836d commit f71c330

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ruby/extractor/src/diagnostics.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,19 @@ impl DiagnosticLoggers {
200200
}
201201

202202
fn longest_backtick_sequence_length(text: &str) -> usize {
203+
let mut result = 0;
203204
let mut count = 0;
204205
for c in text.chars() {
205206
if c == '`' {
206207
count += 1;
207208
} else {
209+
if count > result {
210+
result = count;
211+
}
208212
count = 0;
209213
}
210214
}
211-
count
215+
result
212216
}
213217
impl DiagnosticMessage {
214218
pub fn full_error_message(&self) -> String {
@@ -326,7 +330,10 @@ fn test_message() {
326330
let mut m = DiagnosticLoggers::new("foo")
327331
.logger()
328332
.new_entry("id", "name");
329-
m.message("hello with backticks: {}", &["`hello`"]);
330-
assert_eq!("hello with backticks: `hello`", m.plaintext_message);
331-
assert_eq!("hello with backticks: `` `hello` ``", m.markdown_message);
333+
m.message("hello with backticks: {}", &["oh `hello`!"]);
334+
assert_eq!("hello with backticks: oh `hello`!", m.plaintext_message);
335+
assert_eq!(
336+
"hello with backticks: `` oh `hello`! ``",
337+
m.markdown_message
338+
);
332339
}

0 commit comments

Comments
 (0)