Skip to content

Commit 895ce2d

Browse files
committed
motiontrail: fix crash on invalid selection idx
1 parent 23abc4f commit 895ce2d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@
20022002
"id": "motiontrail",
20032003
"mod_version": "3.1",
20042004
"path": "plugins/motiontrail.lua",
2005-
"version": "0.3"
2005+
"version": "0.4"
20062006
},
20072007
{
20082008
"description": "Allows moving back and forward between document positions, reducing the amount of scrolling",

plugins/motiontrail.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ core.add_thread(function()
3939
end)
4040

4141
local function get_caret_size(dv, i)
42-
local line, col = dv.doc:get_selection_idx(i)
43-
local chw = dv:get_font():get_width(dv.doc:get_char(line, col))
4442
local w = style.caret_width
4543
local h = dv:get_line_height()
4644

45+
local line, col = dv.doc:get_selection_idx(i)
46+
if not line or not col then return w, h end
47+
local chw = dv:get_font():get_width(dv.doc:get_char(line, col))
48+
4749
if dv.doc.overwrite then
4850
w = chw
4951
h = style.caret_width * 2

0 commit comments

Comments
 (0)