From 820dbd1a2e94eb33f72c1acc7092070791121e02 Mon Sep 17 00:00:00 2001 From: Dhanush Shetty <154754292+dhanush0x96c@users.noreply.github.com> Date: Fri, 20 Feb 2026 00:38:39 +0530 Subject: [PATCH] fix(ui): rendering issues when opening files with -t flag When passing a file via the CLI with the TUI flag (-t), the -w flag was ignored and window resizing would result in a blank screen. This was caused by the file content not being stored in currentDocument.Body during Init(). Consequently, the first WindowSizeMsg triggered a re-render with an empty body, discarding the initial content. Replaced manual file reading in Init() with loadLocalMarkdown() to ensure the body is correctly stored and a fetchedMarkdownMsg is emitted. This ensures content is preserved during re-renders and that the word wrap width is correctly applied. Fixes #878 --- ui/ui.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ui/ui.go b/ui/ui.go index 3537d3f..af92458 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -190,13 +190,7 @@ func (m model) Init() tea.Cmd { case stateShowStash: cmds = append(cmds, findLocalFiles(*m.common)) case stateShowDocument: - content, err := os.ReadFile(m.common.cfg.Path) - if err != nil { - log.Error("unable to read file", "file", m.common.cfg.Path, "error", err) - return func() tea.Msg { return errMsg{err} } - } - body := string(utils.RemoveFrontmatter(content)) - cmds = append(cmds, renderWithGlamour(m.pager, body)) + cmds = append(cmds, loadLocalMarkdown(&m.pager.currentDocument)) } return tea.Batch(cmds...)