mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
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>
This commit is contained in:
parent
222cfe7daf
commit
3719cdd48e
|
@ -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
|
||||
|
|
|
@ -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)))))
|
||||
(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)))))
|
||||
(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"
|
||||
|
|
Loading…
Reference in a new issue