[gitg] Deep extend diff settings to preserve defaults



commit 355711267609144a2da0fd9c893374a70e3f7688
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sun Mar 15 10:57:04 2015 +0100

    Deep extend diff settings to preserve defaults

 libgitg/resources/ui/diff-view/diff-view.js |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/libgitg/resources/ui/diff-view/diff-view.js b/libgitg/resources/ui/diff-view/diff-view.js
index 1d9d9ab..7fdbd95 100644
--- a/libgitg/resources/ui/diff-view/diff-view.js
+++ b/libgitg/resources/ui/diff-view/diff-view.js
@@ -15,7 +15,7 @@ var params = function(query) {
        return ret;
 }(document.location.search.substring(1));
 
-var settings = {
+var default_settings = {
        wrap: true,
        tab_width: 4,
        debug: false,
@@ -34,10 +34,15 @@ var settings = {
 };
 
 var avatar_cache = {};
+var settings;
 
 if ('settings' in params)
 {
-       $.extend(settings, JSON.parse(params.settings));
+       settings = $.extend(true, {}, default_settings, JSON.parse(params.settings));
+}
+else
+{
+       settings = default_settings;
 }
 
 var escapeDiv = document.createElement('div');
@@ -516,7 +521,7 @@ function update_diff(id, lsettings)
 
        if (typeof lsettings != 'undefined')
        {
-               $.extend(settings, lsettings);
+               settings = $.extend(true, {}, default_settings, lsettings);
        }
 
        workeruri = 'diff-view-html-builder.js';


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