From 39da022fcc34cac8cfdc1bfef7353da39f0a91f7 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Fri, 15 May 2026 15:48:50 +1000 Subject: [PATCH] docs: update `CHANGELOG.md` for #2537 and #2561 (#2583) --- CHANGELOG.md | 2 ++ doc.md | 2 +- doc.txt | 5 +++-- lf.1 | 8 +++++--- misc.go | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4925be6..6d37ffd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - The client server connection will now exclusively use Unix domain sockets on Windows and no longer fall back to TCP sockets (#2527). - The fallback location of the server socket (used if `XDG_RUNTIME_DIR` is not defined) is changed from `/tmp/lf..sock` to `/tmp/lf-/lf.sock`, and the containing directory must be owned by the current user (#2532). - The `ignorecase` and `ignoredia` options (intended for searching) no longer affect sorting, and instead `sortignorecase` and `sortignoredia` have been added to customize sorting (#2543). +- Previews are now marked as binary if they contain a control character other than bell, backspace, tab, newline, vertical tab, form feed, carriage return, escape or delete (#2561). Previously only null bytes were used to detect binary previews. ### Added @@ -47,6 +48,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - The number of bytes read is now limited for previews that contain extremely long lines (#2458). - Control characters are now stripped from previews to prevent dangerous terminal sequences from being processed if the default previewer is used (#2459). - Sixel images with the same height as the preview window are now displayed correctly when using `tmux` (#2474). +- A bug where previews were loaded according to the old dimensions of the preview window following a terminal resize is now fixed (#2491). - Completion matches are now properly aligned if they contain terminal sequences (#2511). - `load` commands are now processed when the `watch` option is enabled, which should fix various issues with refreshing updated files/directories (#2513). - Parsing octal values in strings are now restricted to numbers between `0` and `255` (#2516). diff --git a/doc.md b/doc.md index 43e68c64..cf64442d 100644 --- a/doc.md +++ b/doc.md @@ -1077,7 +1077,7 @@ Note that preserving other attributes like ownership of change/birth timestamp i Show previews of files and directories at the rightmost pane. If the file has more lines than the preview pane, the rest of the lines are not read. -Files are considered binary and displayed as `binary` if the read portion contains a control character other than tab, newline, vertical tab, form feed, carriage return, backspace, or escape. +Files are considered binary and displayed as `binary` if the read portion contains a control character other than bell, backspace, tab, newline, vertical tab, form feed, carriage return, escape or delete. ## previewer (string) (default ``) (not filtered if empty) diff --git a/doc.txt b/doc.txt index e5d35022..4071450c 100644 --- a/doc.txt +++ b/doc.txt @@ -1167,8 +1167,9 @@ preview (bool) (default true) Show previews of files and directories at the rightmost pane. If the file has more lines than the preview pane, the rest of the lines are not -read. Files containing the null character (U+0000) in the read portion -are considered binary files and displayed as binary. +read. Files are considered binary and displayed as binary if the read +portion contains a control character other than bell, backspace, tab, +newline, vertical tab, form feed, carriage return, escape or delete. previewer (string) (default ``) (not filtered if empty) diff --git a/lf.1 b/lf.1 index 4aeb19db..890bbe0f 100644 --- a/lf.1 +++ b/lf.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 3.7.0.2 .\" -.TH "LF" "1" "2026\-05\-02" "r42" "DOCUMENTATION" +.TH "LF" "1" "2026\-05\-15" "r42" "DOCUMENTATION" .SH NAME lf \- terminal file manager .SH SYNOPSIS @@ -1031,8 +1031,10 @@ timestamp is desirable, but not portably supported in Go. Show previews of files and directories at the rightmost pane. If the file has more lines than the preview pane, the rest of the lines are not read. -Files containing the null character (U+0000) in the read portion are -considered binary files and displayed as \f[CR]binary\f[R]. +Files are considered binary and displayed as \f[CR]binary\f[R] if the +read portion contains a control character other than bell, backspace, +tab, newline, vertical tab, form feed, carriage return, escape or +delete. .SS previewer (string) (default \(ga\(ga) (not filtered if empty) Set the path of a previewer file to filter the content of regular files for previewing. diff --git a/misc.go b/misc.go index 3df73529..2fe15310 100644 --- a/misc.go +++ b/misc.go @@ -466,7 +466,7 @@ func deletePathRecursive[T any](m map[string]T, path string) { // Individual lines are truncated to avoid unbounded memory usage on files // with very long or no newlines. // Sixel images are also detected and stored as separate lines. -// The presence of a null byte outside a sixel image indicates a binary file. +// C0 control bytes outside of \a \b \t \n \v \f \r \033 and DEL indicate binary content. func readLines(reader io.ByteReader, maxLines int) (lines []string, binary bool, sixel bool) { const maxLineBytes = 1 << 16 // 64 KiB per line @@ -500,7 +500,7 @@ func readLines(reader io.ByteReader, maxLines int) (lines []string, binary bool, switch currState { case stateNormal: - // C0 controls outside \b \t \n \v \f \r \033 and DEL indicate binary content. + // C0 control bytes outside of \a \b \t \n \v \f \r \033 and DEL indicate binary content. if b < 0x07 || (b > 0x0D && b < 0x1B) || (b > 0x1B && b < 0x20) || b == 0x7F { return nil, true, false }