mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-22 16:14:17 +02:00
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
This commit is contained in:
parent
752de97c5a
commit
820dbd1a2e
1 changed files with 1 additions and 7 deletions
8
ui/ui.go
8
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...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue