diff --git a/plugins/UiFileManager/media/js/FileEditor.coffee b/plugins/UiFileManager/media/js/FileEditor.coffee
index 24275df9..3166881d 100644
--- a/plugins/UiFileManager/media/js/FileEditor.coffee
+++ b/plugins/UiFileManager/media/js/FileEditor.coffee
@@ -127,6 +127,15 @@ class FileEditor extends Class
return false
handleSaveClick: =>
+ num_errors = (mark for mark in Page.file_editor.cm.getAllMarks() when mark.className == "CodeMirror-lint-mark-error").length
+ if num_errors > 0
+ Page.cmd "wrapperConfirm", ["Warning: The file looks invalid.", "Save anyway"], @save
+ else
+ @save()
+ return false
+
+ save: =>
+ Page.projector.scheduleRender()
@is_saving = true
Page.cmd "fileWrite", [@inner_path, Text.fileEncode(@cm.getValue())], (res) =>
@is_saving = false
@@ -144,7 +153,6 @@ class FileEditor extends Class
@mode = "Edit"
Page.file_list.need_update = true
Page.projector.scheduleRender()
- return false
render: ->
if @need_update
diff --git a/plugins/UiFileManager/media/js/all.js b/plugins/UiFileManager/media/js/all.js
index eae5fc11..e8f866ff 100644
--- a/plugins/UiFileManager/media/js/all.js
+++ b/plugins/UiFileManager/media/js/all.js
@@ -1932,6 +1932,7 @@
function FileEditor(inner_path1) {
this.inner_path = inner_path1;
+ this.save = bind(this.save, this);
this.handleSaveClick = bind(this.handleSaveClick, this);
this.handleSidebarButtonClick = bind(this.handleSidebarButtonClick, this);
this.foldJson = bind(this.foldJson, this);
@@ -2095,8 +2096,31 @@
};
FileEditor.prototype.handleSaveClick = function() {
+ var mark, num_errors;
+ num_errors = ((function() {
+ var i, len, ref, results;
+ ref = Page.file_editor.cm.getAllMarks();
+ results = [];
+ for (i = 0, len = ref.length; i < len; i++) {
+ mark = ref[i];
+ if (mark.className === "CodeMirror-lint-mark-error") {
+ results.push(mark);
+ }
+ }
+ return results;
+ })()).length;
+ if (num_errors > 0) {
+ Page.cmd("wrapperConfirm", ["Warning: The file looks invalid.", "Save anyway"], this.save);
+ } else {
+ this.save();
+ }
+ return false;
+ };
+
+ FileEditor.prototype.save = function() {
+ Page.projector.scheduleRender();
this.is_saving = true;
- Page.cmd("fileWrite", [this.inner_path, Text.fileEncode(this.cm.getValue())], (function(_this) {
+ return Page.cmd("fileWrite", [this.inner_path, Text.fileEncode(this.cm.getValue())], (function(_this) {
return function(res) {
_this.is_saving = false;
if (res.error) {
@@ -2117,7 +2141,6 @@
return Page.projector.scheduleRender();
};
})(this));
- return false;
};
FileEditor.prototype.render = function() {
diff --git a/src/Config.py b/src/Config.py
index b50b49ad..d529b8c2 100644
--- a/src/Config.py
+++ b/src/Config.py
@@ -14,7 +14,7 @@ class Config(object):
def __init__(self, argv):
self.version = "0.7.2"
- self.rev = 4536
+ self.rev = 4537
self.argv = argv
self.action = None
self.test_parser = None