From 324634f56d31c6a96be09f9fd19de257011264b9 Mon Sep 17 00:00:00 2001 From: fudesign2008 Date: Tue, 30 Jan 2018 11:29:16 +0800 Subject: [PATCH 1/3] MOD: escape `$` from when run `:Ack` --- autoload/ack.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/ack.vim b/autoload/ack.vim index dbf84572..d3554241 100644 --- a/autoload/ack.vim +++ b/autoload/ack.vim @@ -39,7 +39,13 @@ function! ack#Ack(cmd, args) "{{{ endif " If no pattern is provided, search for the word under the cursor - let l:grepargs = empty(a:args) ? expand("") : a:args . join(a:000, ' ') + if empty(a:args) + let l:grepargs = expand("") + " escape special chars in + let l:grepargs = escape(l:grepargs, '$') + else + let l:grepargs = a:args . join(a:000, ' ') + endif "Bypass search if cursor is on blank string if l:grepargs == "" From 745c5ed92049bac36c03d830b3abbd9cceaf6861 Mon Sep 17 00:00:00 2001 From: fudesign2008 Date: Tue, 30 Jan 2018 11:34:32 +0800 Subject: [PATCH 2/3] modified: autoload/ack.vim --- autoload/ack.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/ack.vim b/autoload/ack.vim index d3554241..a9551995 100644 --- a/autoload/ack.vim +++ b/autoload/ack.vim @@ -41,8 +41,8 @@ function! ack#Ack(cmd, args) "{{{ " If no pattern is provided, search for the word under the cursor if empty(a:args) let l:grepargs = expand("") - " escape special chars in - let l:grepargs = escape(l:grepargs, '$') + " escape special chars in and wrap in ' + let l:grepargs = "'" . escape(l:grepargs, '$') . "'" else let l:grepargs = a:args . join(a:000, ' ') endif From 8c6e2bcfe0e59aa20cb5b1d3cabaedad63a6a533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E4=BA=91=E8=B4=B5=2810073202=29?= Date: Thu, 15 Jun 2023 17:58:57 +0800 Subject: [PATCH 3/3] fix(windows): fix bug on windows --- autoload/ack.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/ack.vim b/autoload/ack.vim index a9551995..a305a621 100644 --- a/autoload/ack.vim +++ b/autoload/ack.vim @@ -42,7 +42,8 @@ function! ack#Ack(cmd, args) "{{{ if empty(a:args) let l:grepargs = expand("") " escape special chars in and wrap in ' - let l:grepargs = "'" . escape(l:grepargs, '$') . "'" + " use " instead of ', for 'xxx' will cause no effect on windows + let l:grepargs = '"' . escape(l:grepargs, '$') . '"' else let l:grepargs = a:args . join(a:000, ' ') endif