mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-19 04:06:43 -04:00
Repaired file completion behavior
This commit is contained in:
parent
f39b501b1a
commit
47c95a62d8
@ -173,7 +173,7 @@ local function getMatchingFiles(pattern)
|
|||||||
local dir = fs.isDirectory(pattern) and pattern or fs.path(pattern) or "/"
|
local dir = fs.isDirectory(pattern) and pattern or fs.path(pattern) or "/"
|
||||||
local name = (dir == pattern) and "" or fs.name(pattern) or ""
|
local name = (dir == pattern) and "" or fs.name(pattern) or ""
|
||||||
for file in fs.list(dir) do
|
for file in fs.list(dir) do
|
||||||
if string.match("/" .. file, "/" .. name) then
|
if string.match(file, "^" .. name) then
|
||||||
res[#res+1] = file
|
res[#res+1] = file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -191,13 +191,19 @@ local function hintHandler(line)
|
|||||||
local matches
|
local matches
|
||||||
if after:find("[/.]") == 1 then
|
if after:find("[/.]") == 1 then
|
||||||
matches = getMatchingFiles(after)
|
matches = getMatchingFiles(after)
|
||||||
|
if #matches == 1 then
|
||||||
|
lastSearch = ""
|
||||||
|
local ret = base .. (space or "") .. after .. matches[1]:gsub(after:match("[/]*(%w+)$"),"",1)
|
||||||
|
return ret:gsub("[^/]$","%1 ")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
matches = getMatchingPrograms(after)
|
matches = getMatchingPrograms(after)
|
||||||
end
|
|
||||||
if #matches == 1 then
|
if #matches == 1 then
|
||||||
lastSearch = ""
|
lastSearch = ""
|
||||||
return matches[1] .. " "
|
return matches[1] .. " "
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if lastSearch == line then
|
if lastSearch == line then
|
||||||
term.write("\n")
|
term.write("\n")
|
||||||
for _, name in ipairs(matches) do term.write(name .. " ", true)end
|
for _, name in ipairs(matches) do term.write(name .. " ", true)end
|
||||||
@ -207,7 +213,8 @@ local function hintHandler(line)
|
|||||||
local matches = getMatchingFiles(after)
|
local matches = getMatchingFiles(after)
|
||||||
if #matches == 1 then
|
if #matches == 1 then
|
||||||
lastSearch = ""
|
lastSearch = ""
|
||||||
return base .. space .. matches[1] .. " "
|
local ret = base .. space .. after .. matches[1]:gsub(after:match("[/]*(%w+)$"),"",1)
|
||||||
|
return ret:gsub("[^/]$","%1 ")
|
||||||
end
|
end
|
||||||
if lastSearch == line then
|
if lastSearch == line then
|
||||||
term.write("\n")
|
term.write("\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user