Fix autocompleting a non existent directory
This commit is contained in:
parent
fd0aa7a6c3
commit
0441b24c21
1 changed files with 16 additions and 10 deletions
|
|
@ -40,6 +40,7 @@ class AutoComplete
|
||||||
if @completions.length == 0
|
if @completions.length == 0
|
||||||
@completions = completeFunc()
|
@completions = completeFunc()
|
||||||
|
|
||||||
|
complete = ''
|
||||||
if @completions.length
|
if @completions.length
|
||||||
complete = @completions[@autoCompleteIndex % @completions.length]
|
complete = @completions[@autoCompleteIndex % @completions.length]
|
||||||
@autoCompleteIndex++
|
@autoCompleteIndex++
|
||||||
|
|
@ -48,7 +49,7 @@ class AutoComplete
|
||||||
if complete.endsWith('/') && @completions.length == 1
|
if complete.endsWith('/') && @completions.length == 1
|
||||||
@resetCompletion()
|
@resetCompletion()
|
||||||
|
|
||||||
return complete
|
return complete
|
||||||
|
|
||||||
getCommandCompletion: (command) ->
|
getCommandCompletion: (command) ->
|
||||||
return @filterByPrefix(@commands, command)
|
return @filterByPrefix(@commands, command)
|
||||||
|
|
@ -63,12 +64,17 @@ class AutoComplete
|
||||||
basePath = path.dirname(filePath)
|
basePath = path.dirname(filePath)
|
||||||
baseName = path.basename(filePath)
|
baseName = path.basename(filePath)
|
||||||
|
|
||||||
files = fs.readdirSync(basePath)
|
try
|
||||||
|
basePathStat = fs.statSync(basePath)
|
||||||
return @filterByPrefix(files, baseName).map((f) =>
|
if basePathStat.isDirectory()
|
||||||
filePath = path.join(basePath, f)
|
files = fs.readdirSync(basePath)
|
||||||
if fs.lstatSync(filePath).isDirectory()
|
return @filterByPrefix(files, baseName).map((f) =>
|
||||||
return command + ' ' + filePath + path.sep
|
filePath = path.join(basePath, f)
|
||||||
else
|
if fs.lstatSync(filePath).isDirectory()
|
||||||
return command + ' ' + filePath
|
return command + ' ' + filePath + path.sep
|
||||||
)
|
else
|
||||||
|
return command + ' ' + filePath
|
||||||
|
)
|
||||||
|
return []
|
||||||
|
catch err
|
||||||
|
return []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue