From 6f03cd8bc76ac942a56bbdb3e488496b593ecad5 Mon Sep 17 00:00:00 2001 From: Stuart Quin Date: Wed, 3 Aug 2016 21:34:49 +0100 Subject: [PATCH] Add support for ~ expansion --- lib/autocomplete.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/autocomplete.coffee b/lib/autocomplete.coffee index d33ffc3..7f8608f 100644 --- a/lib/autocomplete.coffee +++ b/lib/autocomplete.coffee @@ -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 = ''