Skip to content

Commit

Permalink
Use 'max' to ensure non-negative 'size' in 'sml/generate-minor-modes'
Browse files Browse the repository at this point in the history
  • Loading branch information
mola-T committed May 6, 2016
1 parent 0e9cae8 commit 5d3dc38
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions smart-mode-line.el
Original file line number Diff line number Diff line change
Expand Up @@ -1523,21 +1523,22 @@ duplicated buffer names) from being displayed."
(let* (;; The minor-mode-alist
(nameList (rm--mode-list-as-string-list))
;; The size available
(size (- (if (member sml/mode-width '(full right))
;; Calculate how much width is available
(sml/fill-width-available)
;; or use what the user requested.
sml/mode-width)
(string-width (format-mode-line
'sml/pre-minor-modes-separator))
(string-width (format-mode-line
'sml/pos-minor-modes-separator))))
(size (max 0
(- (if (member sml/mode-width '(full right))
;; Calculate how much width is available
(sml/fill-width-available)
;; or use what the user requested.
sml/mode-width)
(string-width (format-mode-line
'sml/pre-minor-modes-separator))
(string-width (format-mode-line
'sml/pos-minor-modes-separator)))))
;; Used for counting size.
(finalNameList (mapconcat 'identity nameList ""))
needs-removing filling)

;; Calculate whether truncation is necessary.
(when (and sml/shorten-modes (> size 0) (> (string-width finalNameList) size))
(when (and sml/shorten-modes (> (string-width finalNameList) size))
;; We need to remove 1+ "the number of spaces found".
(setq needs-removing
(1+
Expand Down

0 comments on commit 5d3dc38

Please sign in to comment.