Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match)



Did a following test and indeed zed on 323 lines long function is still slow

--- a/highlighters/main/main-highlighter.zsh
+++ b/highlighters/main/main-highlighter.zsh
@@ -87,10 +87,10 @@ _zsh_highlight_main_add_region_highlight() {
 # NOTE: This runs 'setopt', but that should be safe since it'll only ever be
 # called inside a $(...) subshell, so the effects will be local.
 _zsh_highlight_main__type() {
-  if (( $#options_to_set )); then
-    setopt $options_to_set;
-  fi
-  LC_ALL=C builtin type -w -- $1 2>/dev/null
+  typeset -a arr
+  arr=( ': reserved' ': suffix alias' ': alias' ': builtin' ':
function' ': command'  ': hashed' )
+  integer len=${#arr}
+  REPLY=${arr[ (RANDOM % len) + 1 ]}
 }

 # Main syntax highlighting function.
@@ -283,7 +283,8 @@ _zsh_highlight_main_highlighter()
      else
       _zsh_highlight_main_highlighter_expand_path $arg
       local expanded_arg="$REPLY"
-      local res="$(_zsh_highlight_main__type ${expanded_arg})"
+      _zsh_highlight_main__type ${expanded_arg}
+      local res="$REPLY"
       () {
         # Special-case: command word is '$foo', like that, without
braces or anything.
         #
@@ -295,7 +296,8 @@ _zsh_highlight_main_highlighter()
         local MATCH; integer MBEGIN MEND
         if [[ $res == *': none' ]] && (( ${+parameters} )) &&
            [[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~
^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]]; then
-          res="$(_zsh_highlight_main__type ${(P)MATCH})"
+          _zsh_highlight_main__type ${(P)MATCH}
+          res="$REPLY"
         fi
       }

Best regards,
Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author