diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
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.
Diffstat (limited to 'custom/extensions/syntax-highlight.lua')
-rw-r--r--custom/extensions/syntax-highlight.lua13
1 file changed, 2 insertions, 11 deletions
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