summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-06-11 17:26:30 -0400
committerDan Davison <dandavison7@gmail.com>2020-06-11 18:01:59 -0400
commit30c5fc9d361287765163c283520b152c26acbaaa (patch)
tree09ef441eaa223cdaab4a99f677e293b0e97cfaf5
parent307e2f8e483e139769f75b1b1b60372a31e5ec3c (diff)
Fix test: force tokenization algorithm to match previous behavior
-rw-r--r--src/edits.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/edits.rs b/src/edits.rs
index 35615dfb..474071ef 100644
--- a/src/edits.rs
+++ b/src/edits.rs
@@ -86,6 +86,9 @@ fn tokenize(line: &str) -> Vec<&str> {
let mut tokens = Vec::new();
let mut offset = 0;
for m in TOKENIZATION_REGEXP.find_iter(line) {
+ if offset == 0 && m.start() > 0 {
+ tokens.push("");
+ }
// Align separating text as multiple single-character tokens.
for i in offset..m.start() {
tokens.push(&line[i..i + 1]);
@@ -94,6 +97,9 @@ fn tokenize(line: &str) -> Vec<&str> {
offset = m.end();
}
if offset < line.len() {
+ if offset == 0 {
+ tokens.push("");
+ }
for i in offset..line.len() {
tokens.push(&line[i..i + 1]);
}
@@ -336,6 +342,7 @@ mod tests {
assert_tokenize(
" let col = Color::from_str(s).unwrap_or_else(|_| die());",
&[
+ "",
" ",
" ",
" ",