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

Re: PATCH: highlight pasted text



Yuri D'Elia wrote:
> But chopping off that newline if it's the last character... hmm, I still
> think that's a good idea.

How about the following? It only strips the newline when pasting at
the end of the buffer with region inactive and only after putting the
unadulterated string in the cut buffer.

I've also added a note to the NEWS file about bracketed paste.

> > does. Though emacs is perhaps not putting duplicates in. It'd be good if
> > some actual emacs users could check that it all makes sense, however.
> It matches the default behavior of 24.* at least.

Good, thanks.

Oliver

diff --git a/NEWS b/NEWS
index d515a60..6e78e30 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ creates a local "scalar" containing the text "one word"
 and an array "array" containing the words "several"
 "words".
 
+- The bracketed paste mode of newer terminal emulators is now supported.
+  This feature allows the shell to differentiate between pasted text and
+  typed-in characters that may include keys with associated functions.
+
 Changes from 5.0.0 to 5.0.8
 ---------------------------
 
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index b040b97..1012fee 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -787,6 +787,11 @@ bracketedpaste(char **args)
 	    zmult = 1;
 	    if (region_active)
 		killregion(zlenoargs);
+	    /* chop a final newline if it's insertion would be hard to
+	     * distinguish by the user from the line being accepted */
+	    else if ((zlecs + (insmode ? 0 : n - 1)) >= zlell &&
+		    wpaste[n-1] == ZWC('\n'))
+		n--;
 	    yankcs = yankb = zlecs;
 	    doinsert(wpaste, n);
 	    yanke = zlecs;



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