Add support for ~ expansion
This commit is contained in:
parent
7e1e03284a
commit
6f03cd8bc7
1 changed files with 9 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
os = require 'os'
|
||||
Ex = require './ex'
|
||||
|
||||
module.exports =
|
||||
|
|
@ -13,6 +14,12 @@ class AutoComplete
|
|||
@autoCompleteText = null
|
||||
@completions = []
|
||||
|
||||
expandTilde: (filePath) ->
|
||||
if filePath.charAt(0) == '~'
|
||||
return os.homedir() + filePath.slice(1)
|
||||
else
|
||||
return filePath
|
||||
|
||||
getAutocomplete: (text) ->
|
||||
if !@autoCompleteText
|
||||
@autoCompleteText = text
|
||||
|
|
@ -48,6 +55,8 @@ class AutoComplete
|
|||
return @filterByPrefix(@commands, command)
|
||||
|
||||
getFilePathCompletion: (command, filePath) ->
|
||||
filePath = @expandTilde(filePath)
|
||||
|
||||
if filePath.endsWith(path.sep)
|
||||
basePath = path.dirname(filePath + '.')
|
||||
baseName = ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue