Add string helper function
This function returns true if a string starts with a given prefix.
This commit is contained in:
parent
1802a44018
commit
e8ad3a32f5
|
@ -79,6 +79,10 @@ function completion.shell(command, cur_pos, ncomp, shell)
|
||||||
local i = 1
|
local i = 1
|
||||||
local comptype = "file"
|
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
|
-- 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
|
if cur_pos ~= #command + 1 and command:sub(cur_pos, cur_pos) ~= " " then
|
||||||
return command, cur_pos
|
return command, cur_pos
|
||||||
|
|
Loading…
Reference in New Issue