mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-16 23:33:28 +00:00
Keep mid-field quotes when splitting with Text to Columns (#2438)
Found while testing crates/engine/src/cmd/data.rs:992 (split_delimited, used by text_to_columns) Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fdba683246
commit
45ee4eceed
3 files changed
+18
-3
No files matched your search
@@ -183,8 +183,11 @@ pub(super) fn split_delimited(text: &str, delims: &[char], consecutive: bool, qu
|
||||
let mut in_q = false;
|
||||
let mut last_delim = false;
|
||||
let mut chars = text.chars().peekable();
|
||||
let mut at_start = true;
|
||||
while let Some(c) = chars.next() {
|
||||
if c == quote {
|
||||
if c == quote && (in_q || at_start) {
|
||||
at_start = false;
|
||||
last_delim = false;
|
||||
if in_q && chars.peek() == Some("e) {
|
||||
cur.push(quote);
|
||||
chars.next();
|
||||
@@ -199,9 +202,11 @@ pub(super) fn split_delimited(text: &str, delims: &[char], consecutive: bool, qu
|
||||
}
|
||||
out.push(std::mem::take(&mut cur));
|
||||
last_delim = true;
|
||||
at_start = true;
|
||||
continue;
|
||||
}
|
||||
last_delim = false;
|
||||
at_start = false;
|
||||
cur.push(c);
|
||||
}
|
||||
out.push(cur);
|
||||
|
||||
Reference in new issue
Block a user