From 8e37cc3247ec6ee73bc843aeb6d8ef8709d8b685 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 22:18:38 -1000 Subject: Drop the highlighter's stale guard and dead branch cgit runs as a CGI, so no interpreter outlives its request, and the lexers load once per process. The loop below already wrote nothing for an empty blob. --- custom/extensions/syntax-highlight.lua | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'custom') diff --git a/custom/extensions/syntax-highlight.lua b/custom/extensions/syntax-highlight.lua index 544fce1..fdc4fa0 100644 --- a/custom/extensions/syntax-highlight.lua +++ b/custom/extensions/syntax-highlight.lua @@ -135,11 +135,7 @@ local function load_scintillua() if not dir then return nil end - -- cgit keeps this interpreter alive across requests, so package.path is - -- only extended when the directory is not already on it. - if not string.find(package.path, dir, 1, true) then - package.path = dir .. "/?.lua;" .. package.path - end + package.path = dir .. "/?.lua;" .. package.path local ok, mod = pcall(require, "lexer") -- A real Scintillua exposes load(), so anything else on the path that -- happens to be called lexer is rejected rather than used. @@ -243,13 +239,8 @@ function filter_close() end end end - local n = #text - if n == 0 then - html("") - return 0 - end local pos = 1 - while pos <= n do + while pos <= #text do html(escape(string.sub(text, pos, pos + slice_bytes - 1))) pos = pos + slice_bytes end -- cgit