One place to pick a buffer's highlighter

Filetype detection (extension or shebang) was written out three times
(two open paths in Editor and the ImGui frontend's per-frame check) and
"highlighter for this filetype, else the null one" five times (Buffer's
copy constructor and assignment, Editor::SwitchTo, :set filetype).
Buffer::ApplyDetectedFiletype and InstallFiletypeHighlighter replace
them. The InvalidateFrom(0) calls after SetHighlighter are dropped:
SetHighlighter already clears the caches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
Claude
2026-09-24 12:19:59 -07:00
committed by Kyle Isom
parent 323e2377fe
commit 927accbca4
5 changed files with 50 additions and 135 deletions
+9
View File
@@ -472,6 +472,15 @@ public:
}
// Enable syntax with the highlighter the filename (or a shebang on the
// first line) calls for, or none for an unknown type.
void ApplyDetectedFiletype();
// Install the highlighter for Filetype() (the null highlighter for an
// empty or unsupported one), creating the engine if needed.
void InstallFiletypeHighlighter();
// Swap journal integration (set by Editor)
void SetSwapRecorder(kte::SwapRecorder *rec)
{