From 884a799b977d5f747ac73d75e9fe7c8e529af349 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 29 Apr 2017 06:17:49 +0200 Subject: autoload/gitcha.vim: Fix match list population Previously, we were using the completion function sample copied from the Vim manual. This function determined `a:findstart` using a match against `\a`, which only matches alphanumeric characters. Git commit SHAs are SHA-1s, which can contain alphanumeric characters. With the previous match regex, if the word to be completed contained numbers, the `a:findstart` match would fail. This resulted in `a:base` being empty, causing all SHAs to be added to the `matches` array. Now we correctly match only the characters that can appear in a SHA-1, and the completion correctly fills in the rest given the start of a SHA. --- autoload/gitcha.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/gitcha.vim b/autoload/gitcha.vim index 0ceebab..7ed45c7 100644 --- a/autoload/gitcha.vim +++ b/autoload/gitcha.vim @@ -8,7 +8,7 @@ function! gitcha#GitSHAComplete(findstart, base) " locate the start of the word let line = getline('.') let start = col('.') - 1 - while start > 0 && line[start - 1] =~ '\a' + while start > 0 && line[start - 1] =~ '[0-9a-f]' let start -= 1 endwhile return start -- cgit v1.2.3