Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphical preview isnt updated properly with custom init.lua #1377

Closed
SolitudeSF opened this issue Jul 31, 2024 · 3 comments
Closed

Graphical preview isnt updated properly with custom init.lua #1377

SolitudeSF opened this issue Jul 31, 2024 · 3 comments
Labels
invalid This doesn't seem right

Comments

@SolitudeSF
Copy link
Contributor

SolitudeSF commented Jul 31, 2024

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

kitty master

yazi --debug output

Yazi
    Version: 0.2.5 (4257b95 2024-07-31)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.2.5

Emulator
    Emulator.via_env: ("xterm-kitty", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kitty

Desktop
    XDG_SESSION_TYPE: Some("tty")
    WAYLAND_DISPLAY : None
    DISPLAY         : Some(":1")

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : Some("/bedrock/cross/bin/bash")
    EDITOR             : Some("kak")
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None
    ZELLIJ_SESSION_NAME: None

Text Opener
    default: Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

tmux
    TMUX   : false
    Version: No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-29
    fzf              : 0.54.0
    fd               : 10.1.0
    rg               : 14.1.0
    chafa            : No such file or directory (os error 2)
    zoxide           : No such file or directory (os error 2)
    7z               : 24.07
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1

Did you try the latest nightly build to see if the problem got fixed?

Yes, and I updated the debug information above (yazi --debug) to the nightly that I tried

Describe the bug

Moving from text preview to graphical (image/video), leaves holes in the image where the text was in the previous preview, with custom init.lua
image

Expected Behavior

no artifacting.

To Reproduce

This section is required in init.lua for artifacting to appear.

function Header:free()
	local handle = io.popen('echo yes')
	local output = handle:read('*a')
	handle:close()
	return ui.Line { ui.Span(string.sub(output, 1, -1) .. " ") }
end

function Header:render()
	local right = ui.Line { self:free(), self:count(), self:tabs() }
	local left = ui.Line { self:cwd(math.max(0, self._area.w - right:width())) }
	return {
		ui.Paragraph(self._area, { left }),
		ui.Paragraph(self._area, { right }):align(ui.Paragraph.RIGHT),
	}
end

preview window must be big enough so that image wont get downscaled.
hover over text file then hover over graphical file. sometimes its racy, but on certain files it always reproduces.

@SolitudeSF SolitudeSF added the bug Something isn't working label Jul 31, 2024
@SolitudeSF
Copy link
Contributor Author

easire init.lua reproducer

function Header:free()
	local handle = io.popen('fsfree')
	local output = handle:read('*a')
	handle:close()
	return ui.Line { ui.Span(string.sub(output, 1, -1) .. " ") }
end

Header:children_add("free", 900, Header.RIGHT)

@sxyazi
Copy link
Owner

sxyazi commented Jan 25, 2025

I guess it's fsfree that's outputting content to stderr, and since io.popen only supports stdout, fsfree's stderr gets directly output to the Yazi UI, which messes up the screen.

Because of this, io.popen is unsafe for Yazi. You should always avoid using it and use Command instead unless you really know what you're doing.

Also, never call external commands in the UI rendering function/process. Instead, you should schedule them asynchronously as a fetcher and merge the results into the UI. Look at how the git and mactag plugin does it.

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2025
@sxyazi sxyazi added invalid This doesn't seem right and removed bug Something isn't working labels Jan 25, 2025
Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please file a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants