Skip to content

Commit 908dbae

Browse files
authored
Merge pull request #3007 from bhcleek/lsp/test/single-newline-insertion
lsp: add test for single newline insertion
2 parents b891cfa + 85ebd56 commit 908dbae

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

autoload/go/lsp_test.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ func! Test_Format() abort
5858
endtry
5959
endfunc
6060

61+
func! Test_Format_SingleNewline() abort
62+
try
63+
let expected = join(readfile("test-fixtures/lsp/fmt/format_golden.go"), "\n")
64+
let l:tmp = gotest#load_fixture('lsp/fmt/newline.go')
65+
66+
call go#lsp#Format()
67+
68+
" this should now contain the formatted code
69+
let actual = join(go#util#GetLines(), "\n")
70+
71+
call assert_equal(expected, actual)
72+
finally
73+
call delete(l:tmp, 'rf')
74+
endtry
75+
endfunc
76+
6177
func! Test_Imports() abort
6278
try
6379
let expected = join(readfile("test-fixtures/lsp/imports/imports_golden.go"), "\n")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package main
2+
3+
import "fmt"
4+
func main() {
5+
fmt.Println("vim-go")
6+
}

autoload/gotest.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fun! gotest#load_fixture(path) abort
5858

5959
call mkdir(fnamemodify(l:full_path, ':h'), 'p')
6060
call go#util#Chdir(l:dir . '/src')
61-
silent exe 'noautocmd e ' . a:path
61+
silent exe 'noautocmd e! ' . a:path
6262
silent exe printf('read %s/test-fixtures/%s', g:vim_go_root, a:path)
6363
silent noautocmd w!
6464
if go#util#has_job()

0 commit comments

Comments
 (0)