Fix #218
This commit is contained in:
parent
f4693a6eee
commit
ac579ab769
|
@ -13,7 +13,7 @@
|
||||||
"Keymap": "wide",
|
"Keymap": "wide",
|
||||||
"Created": 1414080000000000000,
|
"Created": 1414080000000000000,
|
||||||
"Updated": 1414080000000000000,
|
"Updated": 1414080000000000000,
|
||||||
"Lived": 1443322949749873692,
|
"Lived": 1414080000000000000,
|
||||||
"Editor": {
|
"Editor": {
|
||||||
"FontFamily": "Consolas, 'Courier New', monospace",
|
"FontFamily": "Consolas, 'Courier New', monospace",
|
||||||
"FontSize": "13px",
|
"FontSize": "13px",
|
||||||
|
@ -22,12 +22,8 @@
|
||||||
"TabSize": "4"
|
"TabSize": "4"
|
||||||
},
|
},
|
||||||
"LatestSessionContent": {
|
"LatestSessionContent": {
|
||||||
"FileTree": [
|
"FileTree": [],
|
||||||
"/Users/Vanessa/Work/GoGoGo/src"
|
"Files": [],
|
||||||
],
|
|
||||||
"Files": [
|
|
||||||
"/Users/Vanessa/Work/GoGoGo/src/1.css"
|
|
||||||
],
|
|
||||||
"CurrentFile": "",
|
"CurrentFile": "",
|
||||||
"FileTreeLayout": null,
|
"FileTreeLayout": null,
|
||||||
"EditorLayout": null,
|
"EditorLayout": null,
|
||||||
|
|
|
@ -452,8 +452,8 @@ func (sessions *wSessions) new(httpSession *sessions.Session, sid string) *WideS
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case event := <-watcher.Events:
|
case event := <-watcher.Events:
|
||||||
path := event.Name
|
path := filepath.ToSlash(event.Name)
|
||||||
dir := filepath.Dir(path)
|
dir := filepath.ToSlash(filepath.Dir(path))
|
||||||
|
|
||||||
ch = SessionWS[sid]
|
ch = SessionWS[sid]
|
||||||
if nil == ch {
|
if nil == ch {
|
||||||
|
@ -467,14 +467,23 @@ func (sessions *wSessions) new(httpSession *sessions.Session, sid string) *WideS
|
||||||
logger.Warn(err, path)
|
logger.Warn(err, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "create-file"}
|
fileType := "f"
|
||||||
|
|
||||||
|
if util.File.IsDir(path) {
|
||||||
|
fileType = "d"
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := map[string]interface{}{"path": path, "dir": dir,
|
||||||
|
"cmd": "create-file", "type": fileType}
|
||||||
ch.WriteJSON(&cmd)
|
ch.WriteJSON(&cmd)
|
||||||
} else if event.Op&fsnotify.Remove == fsnotify.Remove {
|
} else if event.Op&fsnotify.Remove == fsnotify.Remove {
|
||||||
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "remove-file"}
|
cmd := map[string]interface{}{"path": path, "dir": dir,
|
||||||
|
"cmd": "remove-file", "type": ""}
|
||||||
ch.WriteJSON(&cmd)
|
ch.WriteJSON(&cmd)
|
||||||
|
|
||||||
} else if event.Op&fsnotify.Rename == fsnotify.Rename {
|
} else if event.Op&fsnotify.Rename == fsnotify.Rename {
|
||||||
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "rename-file"}
|
cmd := map[string]interface{}{"path": path, "dir": dir,
|
||||||
|
"cmd": "rename-file", "type": ""}
|
||||||
ch.WriteJSON(&cmd)
|
ch.WriteJSON(&cmd)
|
||||||
}
|
}
|
||||||
case err := <-watcher.Errors:
|
case err := <-watcher.Errors:
|
||||||
|
|
|
@ -170,7 +170,7 @@ var session = {
|
||||||
mode = CodeMirror.findModeByFileName(name),
|
mode = CodeMirror.findModeByFileName(name),
|
||||||
iconSkin = wide.getClassBySuffix(name.split(".")[1]);
|
iconSkin = wide.getClassBySuffix(name.split(".")[1]);
|
||||||
|
|
||||||
if (data.type && data.type === 'file') {
|
if (data.type && data.type === 'f') {
|
||||||
tree.fileTree.addNodes(dirNode, [{
|
tree.fileTree.addNodes(dirNode, [{
|
||||||
"name": name,
|
"name": name,
|
||||||
"iconSkin": iconSkin,
|
"iconSkin": iconSkin,
|
||||||
|
@ -193,7 +193,8 @@ var session = {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'remove-file':
|
case 'remove-file':
|
||||||
var dirNode = tree.fileTree.getNodeByTId(tree.getTIdByPath(data.dir));
|
case 'rename-file':
|
||||||
|
var dirNode = tree.fileTree.getNodeByTId(tree.getTIdByPath(data.path));
|
||||||
tree.fileTree.removeNode(dirNode);
|
tree.fileTree.removeNode(dirNode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -525,7 +525,7 @@ var tree = {
|
||||||
request = newWideRequest();
|
request = newWideRequest();
|
||||||
|
|
||||||
request.oldPath = wide.curNode.path;
|
request.oldPath = wide.curNode.path;
|
||||||
request.newPath = wide.curNode.path.substring(0, wide.curNode.path.lastIndexOf("/")) + name;
|
request.newPath = wide.curNode.path.substring(0, wide.curNode.path.lastIndexOf("/") +1) + name;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
|
@ -180,20 +180,8 @@ var wide = {
|
||||||
$(".bottom-window-group .notification").focus();
|
$(".bottom-window-group .notification").focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mode = CodeMirror.findModeByFileName(name);
|
|
||||||
|
|
||||||
$("#dialogNewFilePrompt").dialog("close");
|
$("#dialogNewFilePrompt").dialog("close");
|
||||||
var iconSkin = wide.getClassBySuffix(name.split(".")[1]);
|
|
||||||
|
|
||||||
tree.fileTree.addNodes(wide.curNode, [{
|
|
||||||
"name": name,
|
|
||||||
"iconSkin": iconSkin,
|
|
||||||
"path": request.path,
|
|
||||||
"mode": mode,
|
|
||||||
"removable": true,
|
|
||||||
"creatable": true
|
|
||||||
}]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -232,15 +220,6 @@ var wide = {
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#dialogNewDirPrompt").dialog("close");
|
$("#dialogNewDirPrompt").dialog("close");
|
||||||
|
|
||||||
tree.fileTree.addNodes(wide.curNode, [{
|
|
||||||
"name": name,
|
|
||||||
"iconSkin": "ico-ztree-dir ",
|
|
||||||
"path": request.path,
|
|
||||||
"removable": true,
|
|
||||||
"creatable": true,
|
|
||||||
"isParent": true
|
|
||||||
}]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue