From e8ad3a32f58a1562c429bbd04b57e8dda8d86dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Gamb=C3=B6ck?= Date: Sun, 2 Jul 2017 16:15:48 +0200 Subject: [PATCH] Add string helper function This function returns true if a string starts with a given prefix. --- lib/awful/completion.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/awful/completion.lua b/lib/awful/completion.lua index 3b63e8d9..a496a78b 100644 --- a/lib/awful/completion.lua +++ b/lib/awful/completion.lua @@ -79,6 +79,10 @@ function completion.shell(command, cur_pos, ncomp, shell) local i = 1 local comptype = "file" + local function str_starts(str, start) + return string.sub(str, 1, string.len(start)) == start + end + -- do nothing if we are on a letter, i.e. not at len + 1 or on a space if cur_pos ~= #command + 1 and command:sub(cur_pos, cur_pos) ~= " " then return command, cur_pos