Browse Source

修复一处编辑时的问题。

oldj 8 years ago
parent
commit
94c4e2c8aa
4 changed files with 14 additions and 6 deletions
  1. 6 2
      app/bundle.js
  2. 1 1
      app/menu/main_menu.js
  3. 1 1
      app/version.js
  4. 6 2
      ui/content/editor.js

+ 6 - 2
app/bundle.js

@@ -21592,8 +21592,12 @@ var Editor = function (_React$Component) {
       var _this4 = this;
 
       // console.log(next_props);
-      this.codemirror.getDoc().setValue(next_props.code);
-      this.codemirror.setOption('readOnly', next_props.readonly);
+      var cm = this.codemirror;
+      var v = cm.getDoc().getValue();
+      if (v !== next_props.code) {
+        cm.getDoc().setValue(next_props.code);
+      }
+      cm.setOption('readOnly', next_props.readonly);
       setTimeout(function () {
         _this4.highlightKeyword();
       }, 100);

+ 1 - 1
app/menu/main_menu.js

@@ -181,7 +181,7 @@ function doInit (app, lang) {
         }, {
           label: lang.homepage,
           click () {
-            shell.openExternal('http://oldj.github.io/SwitchHosts/')
+            shell.openExternal('https://oldj.github.io/SwitchHosts/')
           }
         }]
     }

+ 1 - 1
app/version.js

@@ -1 +1 @@
-exports.version = [3,3,0,4497];
+exports.version = [3,3,0,4499];

+ 6 - 2
ui/content/editor.js

@@ -112,8 +112,12 @@ export default class Editor extends React.Component {
 
   componentWillReceiveProps (next_props) {
     // console.log(next_props);
-    this.codemirror.getDoc().setValue(next_props.code)
-    this.codemirror.setOption('readOnly', next_props.readonly)
+    let cm = this.codemirror
+    let v = cm.getDoc().getValue()
+    if (v !== next_props.code) {
+      cm.getDoc().setValue(next_props.code)
+    }
+    cm.setOption('readOnly', next_props.readonly)
     setTimeout(() => {
       this.highlightKeyword()
     }, 100)