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
Changing preview_script on-the-fly fails #1483
Comments
It looks like doing a 'reset' after changing preview_script fixes this problem. I'm not sure if it affects other things though. Is there a way of flushing the preview cache without doing a full reset? |
I added a simple command that clears the preview cache. I've also tried it in actons.py (different syntax of course) so I'll make a very small PR for it:
map chain set preview_script ~/.config/ranger/hexview.zsh; reset_previews; redraw_window This seems to work fine. For some reason adding the redraw command in the function doesn't work - i.e. self.fm.draw_window. |
Hmm, @slackhead, could you investigate that issue further? Not ergonomic enough to include with ranger if you have to remember to redraw anyway imo : / |
Yes, I'll take a look at it. |
OK, so marking the window for redraw accomplishes it: self.fm.previews = {} I mailed a patch directly to Hut, rather than making a PR. |
Hut's pretty busy so a PR might get merged faster but you do you. |
Runtime Environment
ranger version: ranger 1.9.2
Python version: 3.6.7 (default, Feb 4 2019, 07:50:16) [GCC 5.5.0]
Locale: en_GB.UTF-8
Current Behavior
When doing :set preview_script /path/to/script on first starting ranger, it is OK so long as no files have been previewed yet. It seems to have random behaviour if you have previewed any. That's the first problem, which may be releated to the greater problem.
After previewing some files (in my case I'm using a custom hex edit script) and then using :set to go back to the default ~/.config/ranger/scope.sh it doesn't not work. It carries on using the custom script.
There is no error at all. It just continues to show files in my hex script.
Expected Behavior
Ranger should be able to change preview scripts on-the-fly.
Context
I sometimes would like to hex view all the files in a directory. My custom script uses xxd to do this.
Possible Solutions
Does ranger cache preview info somewhere? Can it be cleared?
Steps to reproduce
This is my script if you want to test it. It's a zsh script. I'm not sure if sh/bash can do the calcualtions.
#!/bin/zsh
IN=$(xxd -g0 -c1 -u "$1" | head -n $2)
printf "%-9b %3b %3b %3b %3b %-8b\n" "OFFSET" "ASC" "HEX" "DEC" "OCT" "BIN"${#BIN} -lt 8 ] && BINFMT="%0$ ((8-${#BIN}))i%s" || BINFMT="%n%s"
while read -r OFF HEX ASC; do
DEC=$((0x$HEX))
OCT=$(([##8]0x$HEX))
BIN=$(([##2]0x$HEX))
[
done <<< "$IN"
The text was updated successfully, but these errors were encountered: