branch: externals/csv-mode
commit 56ed871dc2feb9a12dce84a590ef9f049cc0405a
Author: Filipp Gunbin <fgun...@fastmail.fm>
Commit: Filipp Gunbin <fgun...@fastmail.fm>

    Fix skipping of empty fields when transposing rows with quotes
    
    * csv-mode.el (csv--collect-fields): Don't do csv-forward-field if on
    separator, otherwise empty fields are missed.
---
 csv-mode.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/csv-mode.el b/csv-mode.el
index 24ed55b7fb..c78c44222e 100644
--- a/csv-mode.el
+++ b/csv-mode.el
@@ -1321,7 +1321,10 @@ point is assumed to be at the beginning of the line."
        (split-string row-text csv-separator-regexp)
       (save-excursion
        (while (< (setq field-start (point)) row-end-position)
-         (csv-forward-field 1)
+          ;; csv-forward-field will skip a separator if point is on
+          ;; it, and we'll miss an empty field
+          (unless (memq (following-char) csv-separator-chars)
+           (csv-forward-field 1))
          (push
           (buffer-substring-no-properties field-start (point))
           fields)

Reply via email to