[gnome-shell] extensionPrefs: Avoid awkward indentation in string literal



commit 95b80eec01edec6a18e22288095021f8fb9da5c2
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 12 15:16:08 2019 +0100

    extensionPrefs: Avoid awkward indentation in string literal
    
    The current code is carefully avoiding an overly wide line length as
    well as adding literal new lines to the string due to indentation. It's
    clever and barely legible.
    
    Instead, use one string per line similar to how they appear in the actual
    output, and join them together when setting the clipboard text.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/608

 js/extensionPrefs/main.js | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index b0be67f49..af1ad08d5 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -168,13 +168,20 @@ var Application = class {
 
         copyButton.connect('clicked', w => {
             let clipboard = Gtk.Clipboard.get_default(w.get_display());
-            let backticks = '```';
-            clipboard.set_text(
-                // markdown for pasting in gitlab issues
-                `The settings of extension ${extension.uuid} had an error:\n${
-                backticks}\n${exc}\n${backticks}\n\nStack trace:\n${
-                backticks}\n${exc.stack}${backticks}\n`, -1
-            );
+            // markdown for pasting in gitlab issues
+            let lines = [
+                `The settings of extension ${extension.uuid} had an error:`,
+                '```',
+                `${exc}`,
+                '```',
+                '',
+                'Stack trace:',
+                '```',
+                exc.stack.replace(/\n$/, ''), // stack without trailing newline
+                '```',
+                ''
+            ];
+            clipboard.set_text(lines.join('\n'), -1);
         });
 
         let spacing = new Gtk.SeparatorToolItem({ draw: false });


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