Skip to content

Commit

Permalink
fix: Calculate correct window end
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Mar 11, 2024
1 parent 5cea267 commit 65cff3b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
:type 'function
:group 'sideline)

(defvar-local sideline--overlays (make-hash-table)
(defvar-local sideline--overlays nil
"Displayed overlays.")

(defvar-local sideline--ex-bound-or-point nil
Expand Down Expand Up @@ -187,6 +187,10 @@

(defun sideline--enable ()
"Enable `sideline' in current buffer."
;; XXX: Still don't know why local variable doesn't work!
(progn
(sideline--delete-ovs)
(setq-local sideline--overlays (make-hash-table)))
(setq sideline--ex-bound-or-point t ; render immediately
sideline--text-scale-mode-amount text-scale-mode-amount)
(add-hook 'post-command-hook #'sideline--post-command nil t))
Expand Down Expand Up @@ -258,6 +262,17 @@
"Convert COLUMN to point."
(save-excursion (move-to-column (max column 0)) (point)))

(defun sideline--modeline-height ()
"Return lines modeline cost."
(ceiling (/ (float (window-mode-line-height)) (frame-char-height))))

(defun sideline--window-end ()
"Return the accurate window end position."
(save-excursion
(goto-char (window-end))
(forward-line (- 0 (sideline--modeline-height)))
(line-beginning-position)))

(defun sideline--window-width ()
"Correct window width for sideline."
(window-max-chars-per-line))
Expand Down Expand Up @@ -463,7 +478,7 @@ FACE, NAME, ON-LEFT, and ORDER for details."
(if on-left (format sideline-format-left text)
(format sideline-format-right text))))
(len-title (sideline--str-len title))
(bol (window-start)) (eol (window-end))
(bol (window-start)) (eol (sideline--window-end))
(pos-ov (sideline--find-line len-title on-left bol eol order))
(pos-start (car pos-ov)) (pos-end (cdr pos-ov))
(offset (if (or on-left (zerop (window-hscroll))) 0
Expand Down

0 comments on commit 65cff3b

Please sign in to comment.