Show More
@@ -73,6 +73,21 b' function($,' | |||||
73 | // Setting the file's initial value creates a history entry, |
|
73 | // Setting the file's initial value creates a history entry, | |
74 | // which we don't want. |
|
74 | // which we don't want. | |
75 | cm.clearHistory(); |
|
75 | cm.clearHistory(); | |
|
76 | that._set_mode_for_model(model); | |||
|
77 | that.save_enabled = true; | |||
|
78 | that.generation = cm.changeGeneration(); | |||
|
79 | that.events.trigger("file_loaded.Editor", model); | |||
|
80 | }, | |||
|
81 | function(error) { | |||
|
82 | cm.setValue("Error! " + error.message + | |||
|
83 | "\nSaving disabled."); | |||
|
84 | that.save_enabled = false; | |||
|
85 | } | |||
|
86 | ); | |||
|
87 | }; | |||
|
88 | ||||
|
89 | Editor.prototype._set_mode_for_model = function (model) { | |||
|
90 | /** Set the CodeMirror mode based on the file model */ | |||
76 |
|
91 | |||
77 |
|
|
92 | // Find and load the highlighting mode, | |
78 |
|
|
93 | // first by mime-type, then by file extension | |
@@ -87,18 +102,8 b' function($,' | |||||
87 |
|
|
102 | } | |
88 |
|
|
103 | } | |
89 |
|
|
104 | if (modeinfo) { | |
90 |
|
|
105 | this.set_codemirror_mode(modeinfo); | |
91 |
|
|
106 | } | |
92 | that.save_enabled = true; |
|
|||
93 | that.generation = cm.changeGeneration(); |
|
|||
94 | that.events.trigger("file_loaded.Editor", model); |
|
|||
95 | }, |
|
|||
96 | function(error) { |
|
|||
97 | cm.setValue("Error! " + error.message + |
|
|||
98 | "\nSaving disabled."); |
|
|||
99 | that.save_enabled = false; |
|
|||
100 | } |
|
|||
101 | ); |
|
|||
102 | }; |
|
107 | }; | |
103 |
|
108 | |||
104 | Editor.prototype.set_codemirror_mode = function (modeinfo) { |
|
109 | Editor.prototype.set_codemirror_mode = function (modeinfo) { | |
@@ -120,9 +125,10 b' function($,' | |||||
120 | var parent = utils.url_path_split(this.file_path)[0]; |
|
125 | var parent = utils.url_path_split(this.file_path)[0]; | |
121 | var new_path = utils.url_path_join(parent, new_name); |
|
126 | var new_path = utils.url_path_join(parent, new_name); | |
122 | return this.contents.rename(this.file_path, new_path).then( |
|
127 | return this.contents.rename(this.file_path, new_path).then( | |
123 |
function ( |
|
128 | function (model) { | |
124 |
that.file_path = |
|
129 | that.file_path = model.path; | |
125 |
that.events.trigger('file_renamed.Editor', |
|
130 | that.events.trigger('file_renamed.Editor', model); | |
|
131 | that._set_mode_for_model(model); | |||
126 | } |
|
132 | } | |
127 | ); |
|
133 | ); | |
128 | }; |
|
134 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now