From 16be44154cf823332332d1df995ae1ed50ff43c4 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 28 Jun 2026 06:42:00 -0400 Subject: fix: don't auto-fit the loading placeholder to a huge font With auto-fit on, the one-line "Loading..." placeholder was sized to fill the window height (capped huge), and a reused buffer kept the previous weather's auto-fitted font while loading. Auto-fit now runs only once real weather has rendered, and the placeholder resets to the base font. --- tests/test-wttrin--update-layout.el | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test-wttrin--update-layout.el (limited to 'tests') diff --git a/tests/test-wttrin--update-layout.el b/tests/test-wttrin--update-layout.el new file mode 100644 index 0000000..b8df665 --- /dev/null +++ b/tests/test-wttrin--update-layout.el @@ -0,0 +1,39 @@ +;;; test-wttrin--update-layout.el --- Auto-fit gating -*- lexical-binding: t; -*- + +;; Copyright (C) 2024-2026 Craig Jennings + +;;; Commentary: +;; Auto-fit must not size the transient "Loading..." placeholder to fill the +;; window; it runs only once real weather has rendered. + +;;; Code: + +(require 'ert) +(require 'cl-lib) +(require 'wttrin) +(require 'testutil-wttrin) + +(ert-deftest test-wttrin--update-layout-error-skips-fit-on-placeholder () + "Error: with auto-fit on, the loading placeholder (weather not rendered) is +not auto-fitted; the fit runs only after weather renders." + (let ((buf (get-buffer-create "*wttrin-layout-test*")) + (fit-calls 0)) + (unwind-protect + (save-window-excursion + (cl-letf (((symbol-function 'wttrin--apply-fit-font) + (lambda (&rest _) (setq fit-calls (1+ fit-calls)))) + ((symbol-function 'wttrin--center-buffer) #'ignore)) + (with-current-buffer buf (insert "Loading...")) + (set-window-buffer (selected-window) buf) + (with-current-buffer buf + (let ((wttrin-auto-fit-font t)) + (setq-local wttrin--weather-rendered nil) + (wttrin--update-layout) + (should (= 0 fit-calls)) + (setq-local wttrin--weather-rendered t) + (wttrin--update-layout) + (should (= 1 fit-calls)))))) + (kill-buffer buf)))) + +(provide 'test-wttrin--update-layout) +;;; test-wttrin--update-layout.el ends here -- cgit v1.2.3