From 8e35e4757fbe29b69795c723d742008a0ce236a0 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Sun, 2 Sep 2018 17:31:54 +0300 Subject: [PATCH 1/2] import: fix adding import to empty imports fixes #1534 --- autoload/go/import.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/autoload/go/import.vim b/autoload/go/import.vim index a10df2c8ce..34d73babae 100644 --- a/autoload/go/import.vim +++ b/autoload/go/import.vim @@ -65,6 +65,9 @@ function! go#import#SwitchImport(enabled, localname, path, bang) abort let packageline = line let appendline = line + elseif linestr =~# '^import\s\+(\+)' + let appendline = line + let appendstr = qlocalpath elseif linestr =~# '^import\s\+(' let appendstr = qlocalpath let indentstr = 1 @@ -161,8 +164,15 @@ function! go#import#SwitchImport(enabled, localname, path, bang) abort let linesdelta += 3 let appendstr = qlocalpath let indentstr = 1 + elseif getline(appendline) =~# '^import\s\+(\+)' + call setline(appendline, 'import (') + call append(appendline + 0, appendstr) + call append(appendline + 1, ')') + let linesdelta -= 1 + let indentstr = 1 + else + call append(appendline, appendstr) endif - call append(appendline, appendstr) execute appendline + 1 if indentstr execute 'normal! >>' From 478418b3e29853426d6aa43fc5bc0aeb1137bdf6 Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Sun, 2 Sep 2018 22:01:08 +0300 Subject: [PATCH 2/2] import: fix review comment --- autoload/go/import.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/go/import.vim b/autoload/go/import.vim index 34d73babae..42a61ef16c 100644 --- a/autoload/go/import.vim +++ b/autoload/go/import.vim @@ -164,6 +164,7 @@ function! go#import#SwitchImport(enabled, localname, path, bang) abort let linesdelta += 3 let appendstr = qlocalpath let indentstr = 1 + call append(appendline, appendstr) elseif getline(appendline) =~# '^import\s\+(\+)' call setline(appendline, 'import (') call append(appendline + 0, appendstr)