From 92cd87df83b24e1c45b946bc9eadbe4482de12ba Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Sat, 10 Jul 2010 18:21:25 +0200 Subject: Handle patterns that are too large for Vim to evaluate --- autoload.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'autoload.vim') diff --git a/autoload.vim b/autoload.vim index 025cc2c..4722202 100644 --- a/autoload.vim +++ b/autoload.vim @@ -1,6 +1,6 @@ " Vim script " Maintainer: Peter Odding -" Last Change: June 16, 2010 +" Last Change: July 10, 2010 " URL: http://peterodding.com/code/vim/easytags let s:script = expand(':p:~') @@ -114,8 +114,14 @@ function! easytags#highlight_cmd() " {{{2 if matches != [] call map(matches, 'xolox#escape#pattern(get(v:val, "name"))') let pattern = tagkind.pattern_prefix . '\%(' . join(xolox#unique(matches), '\|') . '\)' . tagkind.pattern_suffix - let command = 'syntax match %s /%s/ containedin=ALLBUT,.*String.*,.*Comment.*' - execute printf(command, hlgroup_tagged, escape(pattern, '/')) + let template = 'syntax match %s /%s/ containedin=ALLBUT,.*String.*,.*Comment.*' + let command = printf(template, hlgroup_tagged, escape(pattern, '/')) + try + execute command + catch /^Vim\%((\a\+)\)\=:E339/ + let msg = "easytags.vim: Failed to highlight %i %s tags because pattern is too big! (%i KB)" + call xolox#warning(printf(msg, len(matches), tagkind.hlgroup, len(pattern) / 1024)) + endtry endif endfor redraw -- cgit v1.2.3