From 6a9e847dec3b7bd00b5451fad14310c17edf022e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 19 Feb 2019 17:05:56 +0100 Subject: [PATCH] org-table: Fix empty field narrowing * lisp/org-table.el (org-table--shrink-field): Fix empty field narrowing. Reported-by: Nick Helm --- lisp/org-table.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 03fcf612d..07903873f 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -3946,11 +3946,14 @@ already hidden." start end (make-string (1+ width) ?-) ""))) ((equal contents "") ;no contents to hide (list - (let ((w (org-string-width (buffer-substring start end)))) - (if (> width w) + (let ((w (org-string-width (buffer-substring start end))) + ;; We really want WIDTH + 2 whitespace, to include blanks + ;; around fields. + (full (+ 2 width))) + (if (<= w full) (org-table--make-shrinking-overlay - (1- end) end (make-string (- (+ width 2) w) ?\s) "") - (org-table--make-shrinking-overlay (- end (- w width 1)) end "" ""))))) + (1- end) end (make-string (- full w) ?\s) "") + (org-table--make-shrinking-overlay (- end (- w full) 1) end "" ""))))) (t ;; If the field is not empty, display exactly WIDTH characters. ;; It can mean to partly hide the field, or extend it with virtual