Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ impl Row {
*index += 1;
if let Some(next_char) = chars.get(*index) {
if *next_char == '"' {
if let Some(prev_char) = chars.get(*index - 1) {
if *prev_char != '\\' {
break;
} else {
continue;
}
};
break;
}
} else {
Expand Down Expand Up @@ -469,6 +476,10 @@ fn is_separator(c: char) -> bool {

#[cfg(test)]
mod test_super {
use std::iter::repeat;

use crate::FileType;

use super::*;

#[test]
Expand Down Expand Up @@ -509,4 +520,23 @@ mod test_super {
assert_eq!(row.find("t", 2, SearchDirection::Forward), Some(4));
assert_eq!(row.find("t", 5, SearchDirection::Forward), Some(5));
}

#[test]
fn string_highlighting_ignores_escaped_quotes() {
let mut row = Row::from(r#""foo\"bar\"""#);
let rust_ft = FileType::from("test.rs");
let opts = rust_ft.highlighting_options();
let mut index = 0;
let chars: Vec<char> = row.string.chars().collect();
let c = chars[index];

row.highlight_string(&mut index, &opts, c, &chars);

assert_eq!(
repeat(highlighting::Type::String)
.take(12)
.collect::<Vec<highlighting::Type>>(),
row.highlighting
)
}
}