From 0ff705fac71c0e7f20c0c7b41fd7ea2a546bf477 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 21 Mar 2019 22:15:04 +0100 Subject: [PATCH] org-colview: Fix out of range error when hscroll is greater than header * lisp/org-colview.el (org-columns-hscroll-title): Fix out of range error when hscroll is greater than header. --- lisp/org-colview.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 5001def0e..7f2a886ad 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -482,13 +482,15 @@ for the duration of the command.") (defun org-columns-hscroll-title () "Set the `header-line-format' so that it scrolls along with the table." (sit-for .0001) ; need to force a redisplay to update window-hscroll - (when (not (= (window-hscroll) org-columns-previous-hscroll)) - (setq header-line-format - (concat (substring org-columns-full-header-line-format 0 1) - (substring org-columns-full-header-line-format - (1+ (window-hscroll)))) - org-columns-previous-hscroll (window-hscroll)) - (force-mode-line-update))) + (let ((hscroll (window-hscroll))) + (when (/= org-columns-previous-hscroll hscroll) + (setq header-line-format + (concat (substring org-columns-full-header-line-format 0 1) + (substring org-columns-full-header-line-format + (min (length org-columns-full-header-line-format) + (1+ hscroll)))) + org-columns-previous-hscroll hscroll) + (force-mode-line-update)))) (defvar org-colview-initial-truncate-line-value nil "Remember the value of `truncate-lines' across colview.")