From b597d858785e933b00e1abc0f004be58cab24520 Mon Sep 17 00:00:00 2001 From: Jagua Date: Thu, 7 Mar 2019 00:41:39 +0900 Subject: Fix missing backslash escape When writing in Go, type the following code, ```go "AA\nBB".log ``` and hits ``, then got the following result. ```go log.Println("AA BB") ``` but want this. ```go log.Println("AA\nBB") ``` --- autoload/sonictemplate.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'autoload') diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index 2c68664..b1ff6a9 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -336,6 +336,7 @@ function! sonictemplate#postfix() return '' endif let line = getline('.')[:col('.')] + let line = escape(line, '\') for k in keys(s:pat[&ft]) let m = matchstr(line, k) if len(m) > 0 -- cgit v1.2.3-54-g00ecf From ae8e1818efe27bb946fd948fc2fe8cc3f38e0e2d Mon Sep 17 00:00:00 2001 From: Jagua Date: Fri, 15 Mar 2019 01:31:25 +0900 Subject: Add more escape I believe that escape() is necessary at 3rd argument of substitute(). example: ```go "%v",&P{}.log ``` and type `` actual: ```go log.Println("%v",{{$1}}P{}) ``` expect: ```go log.Println("%v",&P{}) ``` --- autoload/sonictemplate.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'autoload') diff --git a/autoload/sonictemplate.vim b/autoload/sonictemplate.vim index 913d7d3..9397efa 100644 --- a/autoload/sonictemplate.vim +++ b/autoload/sonictemplate.vim @@ -340,7 +340,7 @@ function! sonictemplate#postfix() return '' endif let line = getline('.')[:col('.')] - let line = escape(line, '\') + let line = escape(line, '\&') for k in keys(s:pat[s:get_raw_filetype()]) let m = matchstr(line, k) if len(m) > 0 -- cgit v1.2.3-54-g00ecf