From 7fa9c39a6b357b37428c5af22bd3a80ebd657c18 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 1 Jul 2008 14:48:48 +0200 Subject: [PATCH] awful: fix UTF-8 char in prompt Signed-off-by: Julien Danjou --- lib/awful.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/awful.lua b/lib/awful.lua index 8a635e977..4213fc70e 100644 --- a/lib/awful.lua +++ b/lib/awful.lua @@ -704,9 +704,11 @@ function P.prompt(args, textbox, exe_callback, completion_callback) elseif key == "Right" then cur_pos = cur_pos + 1 else - if string.len(key) == 1 then + -- len() is UTF-8 aware but #key is not, + -- so check that we have one UTF-8 char but advance the cursor of # position + if key:len() == 1 then command = command:sub(1, cur_pos - 1) .. key .. command:sub(cur_pos) - cur_pos = cur_pos + 1 + cur_pos = cur_pos + #key end end if cur_pos < 1 then