Add string helper function

This function returns true if a string starts with a given prefix.
This commit is contained in:
Florian Gamböck 2017-07-02 16:15:48 +02:00
parent 1802a44018
commit e8ad3a32f5
1 changed files with 4 additions and 0 deletions

View File

@ -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