summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-20 11:57:37 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2018-04-20 11:57:37 +0200
commit3719cdd48e3c580f0b0b1111467ea097265cfded (patch)
tree93362d4762d6e7d4428a7d2e76c3cd8bb140ab22
parent222cfe7daf178c1902ef7cbc9ff55211257a847d (diff)
downloadorg-mode-3719cdd48e3c580f0b0b1111467ea097265cfded.tar.gz
org-table: Fix shrunk hlines
* lisp/org-table.el (org-table--shrink-field): Handle properly shrunk hlines with a width cookie. * testing/lisp/test-org-table.el (test-org-table/toggle-column-width): Add test. Fix tests. Reported-by: William Denton <wtd@pobox.com> <http://lists.gnu.org/r/emacs-orgmode/2018-04/msg00306.html>
-rw-r--r--lisp/org-table.el12
-rw-r--r--testing/lisp/test-org-table.el28
2 files changed, 25 insertions, 15 deletions
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 6616c9a..87060fe 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3937,13 +3937,17 @@ Return a list of overlays hiding the field, or nil if field is
already hidden."
(cond
((org-table--shrunk-field) nil) ;already shrunk: bail out
- ((eq contents 'hline) ;no contents to hide
- (list (org-table--make-shrinking-overlay
- (+ start width 1) end org-table-shrunk-column-indicator contents)))
((or (= 0 width) ;shrink to one character
(>= 1 (org-string-width (buffer-substring start end))))
(list (org-table--make-shrinking-overlay
- start end org-table-shrunk-column-indicator contents)))
+ start end org-table-shrunk-column-indicator
+ (if (eq 'hline contents) "" contents))))
+ ((eq contents 'hline) ;no contents to hide
+ (list (org-table--make-shrinking-overlay
+ start end
+ (concat (make-string (max 0 (1+ width)) ?-)
+ org-table-shrunk-column-indicator)
+ "")))
(t
;; If the field is not empty, consider using two overlays: one for
;; the blanks at the beginning of the field, and another one at
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index 760e6e9..ecef7ea 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -2371,7 +2371,7 @@ See also `test-org-table/copy-field'."
(should-error
(org-test-with-temp-text "<point>a"
(org-table-toggle-column-width)))
- ;; A shrunk columns is overlaid with
+ ;; A shrunk column is overlaid with
;; `org-table-shrunk-column-indicator'.
(should
(equal org-table-shrunk-column-indicator
@@ -2392,17 +2392,15 @@ See also `test-org-table/copy-field'."
'display))))
;; When column is already shrunk, expand it, i.e., remove overlays.
(should-not
- (equal org-table-shrunk-column-indicator
- (org-test-with-temp-text "| <point>a |"
- (org-table-toggle-column-width)
- (org-table-toggle-column-width)
- (overlays-in (point-min) (point-max)))))
+ (org-test-with-temp-text "| <point>a |"
+ (org-table-toggle-column-width)
+ (org-table-toggle-column-width)
+ (overlays-in (point-min) (point-max))))
(should-not
- (equal org-table-shrunk-column-indicator
- (org-test-with-temp-text "| a |\n| <point>b |"
- (org-table-toggle-column-width)
- (org-table-toggle-column-width)
- (overlays-in (point-min) (point-max)))))
+ (org-test-with-temp-text "| a |\n| <point>b |"
+ (org-table-toggle-column-width)
+ (org-table-toggle-column-width)
+ (overlays-in (point-min) (point-max))))
;; With a column width cookie, limit overlay to the specified number
;; of characters.
(should
@@ -2421,6 +2419,14 @@ See also `test-org-table/copy-field'."
(overlay-start
(car (overlays-in (line-beginning-position)
(line-end-position))))))))
+ (should
+ (equal (concat "----" org-table-shrunk-column-indicator)
+ (org-test-with-temp-text "| <3> |\n|--<point>----|"
+ (org-table-toggle-column-width)
+ (overlay-get
+ (car (overlays-in (line-beginning-position)
+ (line-end-position)))
+ 'display))))
;; Width only takes into account visible characters.
(should
(equal "| [[http"