Implemented case-insensitive auto-completion for files
h3rald h3rald@h3rald.com
Fri, 07 Oct 2016 14:52:02 +0200
2 files changed,
7 insertions(+),
13 deletions(-)
M
core/linedit.nim
→
core/linedit.nim
@@ -287,16 +287,10 @@ if words.len > 0:
word = words[words.len-1] else: word = ed.line.fromStart - var rawmatches = compl.filterIt(it.startsWith word) - var matches: seq[string] - if ed.line.fromStart.len > 0: - matches = newSeq[string](0) - for s in rawmatches: - var s1 = s - s1.delete(0, word.len-1) - matches.add s1 - else: - matches = rawmatches + var matches = compl.filterIt(it.toLowerAscii.startsWith(word.toLowerAscii)) + if ed.line.fromStart.len > 0 and matches.len > 0: + for i in 0..word.len: + ed.deletePrevious var n = 0 if matches.len > 0: ed.addToLineAtPosition(matches[0])@@ -307,7 +301,7 @@ while ch == 9:
n.inc if n < matches.len: let diff = ed.line.position - position - for i in 0.countup(diff-1): + for i in 0.countup(diff-1 + word.len): ed.deletePrevious ed.line.position = position ed.addToLineAtPosition(matches[n])
M
minim.nim
→
minim.nim
@@ -97,10 +97,10 @@ var dir: string
if f.contains("/") or dir.contains("\\"): dir = f.parentDir let file = f.extractFileName - return toSeq(walkDir(dir, true)).filterIt(it.path.startsWith(file)).mapIt("\"$1/$2" % [dir, it.path.replace("\\", "/")]) + return toSeq(walkDir(dir, true)).filterIt(it.path.toLowerAscii.startsWith(file.toLowerAscii)).mapIt("\"$1/$2" % [dir, it.path.replace("\\", "/")]) else: dir = getCurrentDir() - return toSeq(walkDir(dir, true)).filterIt(it.path.startsWith(f)).mapIt("\"$1" % [it.path.replace("\\", "/")]) + return toSeq(walkDir(dir, true)).filterIt(it.path.toLowerAscii.startsWith(f.toLowerAscii)).mapIt("\"$1" % [it.path.replace("\\", "/")]) return symbols proc stdLib(i: In) =