editor.highlight_current_line: false is ignored for unnamed buffers restored by hot exit
Description
With "highlight_current_line": false in config.json, the current line is not highlighted in file buffers or in a new unnamed buffer (Ctrl+N). But once an unnamed buffer is restored by hot exit on the next launch, its current line is highlighted, as if the setting were true.
File-backed buffers restored in the same session are not affected. The file extension doesn't matter (.txt, .sh, … all behave correctly).
Steps to reproduce
- Set
"editor": { "highlight_current_line": false }in~/.config/fresh/config.json(hot_exitleft at its defaulttrue). - Start
freshin an empty directory. - Press Ctrl+N and type a few lines. The current line is not highlighted (correct).
- Quit with "Quit (recoverable)" (
qin the unsaved-changes prompt, orforce_quit). - Start
freshagain in the same directory. The unnamed buffer is restored. - Move the cursor. The current line is highlighted.
Expected
The restored unnamed buffer follows editor.highlight_current_line, like file buffers and freshly created unnamed buffers do.
Actual
The restored unnamed buffer always highlights the current line.
Likely cause (from reading the v0.5.1 source)
BufferViewState::newdefaults tohighlight_current_line: true(crates/fresh-editor/src/view/split.rs:279).- File buffers get the config applied through
apply_config_defaultswhen they are opened, andnew_bufferdoes the same for Ctrl+N (crates/fresh-editor/src/app/buffer_management.rs:730). - When restoring a workspace, unnamed buffers come from
restore_unnamed_buffers(crates/fresh-editor/src/app/workspace.rs:2317), and their per-split view state is created withview_state.ensure_buffer_state(buffer_id)(workspace.rs:1465/1551). As far as I can tell,apply_config_defaultsis never called for them, so they keep the hard-coded default. - Only an explicit per-buffer override (
file_state.highlight_current_line) is restored. The global config value is not applied.
Other settings that apply_config_defaults stamps (e.g. line_numbers, wrap_column, rulers) may be affected in the same way, but I only verified highlight_current_line.
Workaround
A user plugin that runs toggle_current_line_highlight twice when an unnamed, non-virtual buffer is activated, and again on plugins_loaded. The latter is needed because the post-restore buffer_activated fires before user plugins are loaded. Running the toggle twice re-stamps the active split's view state from the config without changing the setting.
Environment
- Fresh 0.5.1 (
fresh-editor-bin, Manjaro Linux) - Terminal: WezTerm with
enable_kitty_keyboard = true, COSMIC (Wayland) - Relevant config:
"highlight_current_line": false,hot_exitdefault (true)
Source: sinelaw/fresh