[polari] entryArea: Trim newline(s)/space(s) in pasted text



commit 165c6fb6b1a74c17d99d38ca20336d225b0e9164
Author: raresv <rares visalom gmail com>
Date:   Tue Feb 2 19:35:56 2016 +0200

    entryArea: Trim newline(s)/space(s) in pasted text
    
    Remove extra newlines or spaces surrounding the pasted text
    to prevent unwanted newlines/spaces from being pasted and
    sent to pastebin.
    
    Unnecessary whitespace around the selected text is not useful
    and it usually appears as an odd behaviour when selecting
    multiline text from webpages.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760497

 src/entryArea.js |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/src/entryArea.js b/src/entryArea.js
index 06934ba..416671f 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -35,6 +35,8 @@ const ChatEntry = new Lang.Class({
         let clipboard = Gtk.Clipboard.get_default(this.get_display());
         clipboard.request_text(Lang.bind(this,
             function(clipboard, text) {
+               text = text.trim();
+
                 let nLines = text.split('\n').length;
                 if (nLines >= MAX_LINES) {
                     this.emit('text-pasted', text, nLines);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]