保存文件时,未修改的不需要再次保存
This commit is contained in:
		
							parent
							
								
									2c20093661
								
							
						
					
					
						commit
						7cb70347bf
					
				|  | @ -28,13 +28,16 @@ var editors = { | |||
|                     return false; | ||||
|                 } | ||||
| 
 | ||||
|                 // 移除编辑器
 | ||||
|                 for (var i = 0, ii = editors.data.length; i < ii; i++) { | ||||
|                     if (editors.data[i].id === id) { | ||||
| 
 | ||||
|                         wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); | ||||
|                         editors.data.splice(i, 1); | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 if (editors.data.length === 0) { // 起始页可能存在,所以用编辑器数据判断
 | ||||
|                     menu.disabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']); | ||||
|                     $(".toolbars").hide(); | ||||
|  | @ -51,6 +54,7 @@ var editors = { | |||
|                 } | ||||
| 
 | ||||
|                 if (nextId === editors.tabs.getCurrentId()) { | ||||
|                     // 关闭的不是当前编辑器
 | ||||
|                     return false; | ||||
|                 } | ||||
| 
 | ||||
|  | @ -219,6 +223,7 @@ var editors = { | |||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                     // 清除未保存状态
 | ||||
|                     editor.doc.markClean(); | ||||
|                     $(".edit-panel .tabs > div.current > span").removeClass("changed"); | ||||
|                 } | ||||
|  |  | |||
|  | @ -470,9 +470,6 @@ var wide = { | |||
|         if ($(".menu li.save-all").hasClass("disabled")) { | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         // TODO: 只保存未保存过的文件
 | ||||
| 
 | ||||
|         for (var i = 0, ii = editors.data.length; i < ii; i++) { | ||||
|             this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); | ||||
|         } | ||||
|  | @ -695,6 +692,10 @@ var wide = { | |||
|         }); | ||||
|     }, | ||||
|     fmt: function (path, curEditor) { | ||||
|         if (curEditor.doc.isClean()) { // 没有修改过,不需要保存
 | ||||
|             return false; | ||||
|         } | ||||
|          | ||||
|         var mode = curEditor.getOption("mode"); | ||||
| 
 | ||||
|         var cursor = curEditor.getCursor(); | ||||
|  | @ -749,8 +750,14 @@ var wide = { | |||
|             wide._save(); | ||||
|         } | ||||
| 
 | ||||
|         // 清除未保存状态
 | ||||
|         curEditor.doc.markClean(); | ||||
|         $(".edit-panel .tabs > div.current > span").removeClass("changed"); | ||||
|         $(".edit-panel .tabs > div").each(function () { | ||||
|             var $span = $(this).find("span:eq(0)"); | ||||
|             if ($span.attr("title") === path) { | ||||
|                 $span.removeClass("changed"); | ||||
|             } | ||||
|         }); | ||||
|     }, | ||||
|     openAbout: function () { | ||||
|         $("#dialogAbout").dialog("open"); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue