Skip to content

Commit 7abf10d

Browse files
committed
Ensured minimap works with invalid utf8 characters.
1 parent 73b671f commit 7abf10d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
"description": "Add support for detecting file and string encodings as converting between them.",
384384
"id": "encoding",
385385
"mod_version": "4",
386-
"remote": "https://github.com/adamharrison/lite-xl-encoding.git:56130fe8a35123d0a55be6af618bc82bf1401d7f",
386+
"remote": "https://github.com/adamharrison/lite-xl-encoding.git:4ae17a5ef2050fee68e3d519c32bfce1e5e2b17b",
387387
"type": "library",
388388
"version": "1.1"
389389
},
@@ -394,7 +394,7 @@
394394
"description": "Properly read files that are not encoded in UTF-8 or ASCII by auto-detecting their encoding and allows saving on different text encodings.",
395395
"id": "encodings",
396396
"mod_version": "4",
397-
"remote": "https://github.com/adamharrison/lite-xl-encoding.git:56130fe8a35123d0a55be6af618bc82bf1401d7f",
397+
"remote": "https://github.com/adamharrison/lite-xl-encoding.git:4ae17a5ef2050fee68e3d519c32bfce1e5e2b17b",
398398
"version": "1.0"
399399
},
400400
{

plugins/minimap.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,13 @@ function MiniMap:draw()
490490
local start = 1
491491
while true do
492492
-- find text followed spaces followed by newline
493-
local s, e, w, eol = string.ufind(text, "[^%s]*()[ \t]*()\n?", start)
493+
local is_utf8 = text:ulen()
494+
local s, e, w, eol
495+
if is_utf8 then
496+
s, e, w, eol = text:ufind("[^%s]*()[ \t]*()\n?", start)
497+
else
498+
s, e, w, eol = text:find("[^%s]*()[ \t]*()\n?", start)
499+
end
494500
if not s then break end
495501
local nchars = w - s
496502
start = e + 1

0 commit comments

Comments
 (0)