From 997146248fd202cd2a3eac67c5117ee573732e4d Mon Sep 17 00:00:00 2001 From: garret Date: Fri, 18 Jul 2025 21:43:30 +0100 Subject: em-dash: move cursor properly in insert mode the em-dash character is 3 bytes long. previous behaviour put you in the middle of the character which could corrupt things if you continued typing so we use the actual length of the string in bytes instead --- em-dash.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/em-dash.lua b/em-dash.lua index c52aa1b..7ca18fd 100644 --- a/em-dash.lua +++ b/em-dash.lua @@ -1,7 +1,7 @@ script_name = "Em-dash" script_description = "I do not have an em-dash key on my keyboard" script_author = "garret" -script_version = "2.1.0" +script_version = "2.1.1" local em = "—" @@ -15,7 +15,7 @@ local function insert(sub, sel, act) local start = string.sub(line.text, 1, pos - 1) local end_ = string.sub(line.text, pos) line.text = start .. em .. end_ - aegisub.gui.set_cursor(pos + 1) + aegisub.gui.set_cursor(pos + #em) sub[act] = line end -- cgit v1.2.3-70-g09d2