Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to;
        bh=p3tdFZrzR75+boCOtqLkDtgGjH0lquc4bqMrXf8PbOQ=;
        b=C/jjUcOiA3Wlk6WihxJxrrO3pHPpF0VtlH2W/XxLGdaT0qui8/S52+NHlA9hPqxtSw
         YNmZmRxU+svxEKP+gE0QwV0XB5nUsU7Dwv1GR3+Q1GzVnK99LOQxhkLKeY+asCoXwjJH
         BdIn7v71xvIJVO2kZdM325KxPWBdP8ehCgDRQ8axMpMpSdS4QROhlODI1eMwj71hrolC
         vMziKEJUHZVEybT4Cp1Ud+XENIJAoAa+6v2hvXrIkQHMRa0ksh9JkElhjPf9ZHoTZWAW
         /heXtAuawooIbrvVg5IRb2IRy+t9ir4Lzk9bLR3JtpRwqmYGNtIKvacsCnYxB0AKPBip
         7QjA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:date
         :message-id:subject:from:to;
        bh=p3tdFZrzR75+boCOtqLkDtgGjH0lquc4bqMrXf8PbOQ=;
        b=gTVmZLNAcUE6ga1oIjzsjw58yRej9ZI36WYVW7a5g1Pg2Z2ar+tcOUK53iOhuQv7su
         rNRK+Nm//ZgiXAsBZy+6vRiCndBFcrmunMJ+JGQoWTL2cNdq5BLkDTGhPohQbqxY+96Z
         mq/RnBn0v3WwGOtWhBnZinPa7+zYKn+6PSsgovqW+6MWtrc/IGXLS0zJG5YORXPw1Xmr
         rJ9iXinlw3mYMkuKWJXkTKNFny0pqFSqrY8tTLRi7IKhGVc+6k4lDL1P7E9uc28FPwh1
         mr3r6hmsTD1/WI5WnVTC4VnI5Fr3QqkPX9WawkEw1GNExd/fsD+RIcrLYTByzLgcROJa
         BWeQ==
X-Gm-Message-State: AOPr4FXEjcgzbWmcJadXfDc53/SiwGhHAmC/g/OdTFv8e97VzKxFto0bln9/P8qmdKM74tuL2EK9+SYb/w7fWA==
MIME-Version: 1.0
X-Received: by 10.112.189.73 with SMTP id gg9mr8277120lbc.109.1463310801248;
 Sun, 15 May 2016 04:13:21 -0700 (PDT)
In-Reply-To: <CAKc7PVCZhyjPqzgPSrKOUs=+Qp5m_yELs2uEAwuCQYZXDKkxUg@mail.gmail.com>
References: <CAKc7PVCZhyjPqzgPSrKOUs=+Qp5m_yELs2uEAwuCQYZXDKkxUg@mail.gmail.com>
Date: Sun, 15 May 2016 04:13:21 -0700
Message-ID: <CAH+w=7b7g-g7JmFvrgR4ezWz7CrVZnXVrV+u9iOitX0H0y_pVQ@mail.gmail.com>
Subject: Re: How can Zle -U interfere with zsh-syntax-highlighting?
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
X-Seq: zsh-workers 38494

On Sat, May 14, 2016 at 2:07 PM, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> Below is a widget that outputs long sophisticated string with zle -U:
>
[...]
>
> With z-sy-h enabled, it takes 4 seconds to appear after pressing
> Ctrl-T. Pasting the same text is instant and correct (i.e.
> highlighting works). What can be happening?

This (line 73-74 in current z-sy-h.zsh):

# Do not highlight if there are pending inputs (copy/paste).
[[ $PENDING -gt 0 ]] && return $ret

"zle -U" feeds the input back to zle one character at a time but does
not set PENDING, so I suspect the highlight is being recaculated after
every character.  I suppose it might make sense for "zle -U" to
pretend to be actual input even to the extent of PENDING, but it
currently does not.

This also explains why immediately typing something else speeds things
up:  Highlighting pauses until that character is consumed.

> Is there some alternative to Zle -U?

Other than just LBUFFER+="long text here", no.  If you want the other
effects of zle -U (i.e., that each character is interpreted as if it
had been typed) then there is no alternative.

