From 908c4fe150c4023662462c96f634f6f710000cef Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 24 Sep 2015 17:57:59 +0000 Subject: [PATCH] Stop leaking variables into global namespace. Set WARN_CREATE_GLOBAL to prevent recurrence. Fixes zsh-users/zsh-syntax-highlighting#192. --- highlighters/main/main-highlighter.zsh | 1 + zsh-syntax-highlighting.zsh | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 7f0f3de..dec467a 100755 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -261,6 +261,7 @@ _zsh_highlight_main_highlighter_highlight_string() { setopt localoptions noksharrays local i j k style varflag + local AA # Starting quote is at 1, so start parsing at offset 2 in the string. for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do (( j = i + start_pos - 1 )) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 721d257..a80512c 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -45,7 +45,7 @@ _zsh_highlight() # Store the previous command return code to restore it whatever happens. local ret=$? - setopt localoptions nowarncreateglobal + setopt localoptions warncreateglobal # Do not highlight if there are more than 300 chars in the buffer. It's most # likely a pasted command or a huge list of files in that case.. @@ -125,8 +125,8 @@ _zsh_highlight() } always { - _ZSH_HIGHLIGHT_PRIOR_BUFFER=$BUFFER - _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR + typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER=$BUFFER + typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR } }