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'
|
fs = require 'fs'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
|
os = require 'os'
|
||||||
Ex = require './ex'
|
Ex = require './ex'
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
|
@ -13,6 +14,12 @@ class AutoComplete
|
||||||
@autoCompleteText = null
|
@autoCompleteText = null
|
||||||
@completions = []
|
@completions = []
|
||||||
|
|
||||||
|
expandTilde: (filePath) ->
|
||||||
|
if filePath.charAt(0) == '~'
|
||||||
|
return os.homedir() + filePath.slice(1)
|
||||||
|
else
|
||||||
|
return filePath
|
||||||
|
|
||||||
getAutocomplete: (text) ->
|
getAutocomplete: (text) ->
|
||||||
if !@autoCompleteText
|
if !@autoCompleteText
|
||||||
@autoCompleteText = text
|
@autoCompleteText = text
|
||||||
|
|
@ -48,6 +55,8 @@ class AutoComplete
|
||||||
return @filterByPrefix(@commands, command)
|
return @filterByPrefix(@commands, command)
|
||||||
|
|
||||||
getFilePathCompletion: (command, filePath) ->
|
getFilePathCompletion: (command, filePath) ->
|
||||||
|
filePath = @expandTilde(filePath)
|
||||||
|
|
||||||
if filePath.endsWith(path.sep)
|
if filePath.endsWith(path.sep)
|
||||||
basePath = path.dirname(filePath + '.')
|
basePath = path.dirname(filePath + '.')
|
||||||
baseName = ''
|
baseName = ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue