From 3b8b8ced464b37b932494a5b5a15fbaaa7001840 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 26 Oct 2014 14:46:15 +0800 Subject: [PATCH] Fix #92 --- editor/editors.go | 14 ++++++++------ file/files.go | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/editor/editors.go b/editor/editors.go index 077a93b..c22be21 100644 --- a/editor/editors.go +++ b/editor/editors.go @@ -124,13 +124,15 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) { // glog.Infof("offset: %d", offset) userWorkspace := conf.Wide.GetUserWorkspace(username) + workspaces := strings.Split(userWorkspace, conf.PathListSeparator) + libPath := "" + for _, workspace := range workspaces { + userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator + + runtime.GOOS + "_" + runtime.GOARCH + libPath += userLib + conf.PathListSeparator + } - //glog.Infof("User [%s] workspace [%s]", username, userWorkspace) - userLib := userWorkspace + conf.PathSeparator + "pkg" + conf.PathSeparator + - runtime.GOOS + "_" + runtime.GOARCH - - libPath := userLib - //glog.Infof("gocode set lib-path %s", libPath) + glog.V(5).Infof("gocode set lib-path %s", libPath) // FIXME: 使用 gocode set lib-path 在多工作空间环境下肯定是有问题的,需要考虑其他实现方式 gocode := conf.Wide.GetGocode() diff --git a/file/files.go b/file/files.go index 7e3edbf..140bd89 100644 --- a/file/files.go +++ b/file/files.go @@ -45,9 +45,24 @@ func GetFiles(w http.ResponseWriter, r *http.Request) { session, _ := session.HTTPSession.Get(r, "wide-session") username := session.Values["username"].(string) - userSrc := conf.Wide.GetUserWorkspace(username) + conf.PathSeparator + "src" + userWorkspace := conf.Wide.GetUserWorkspace(username) + workspaces := strings.Split(userWorkspace, conf.PathListSeparator) - root := FileNode{Name: "projects", Path: userSrc, IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}} + root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}} + + // 工作空间节点处理 + for _, workspace := range workspaces { + workspacePath := workspace + conf.PathSeparator + "src" + + workspaceNode := FileNode{Name: workspace[strings.LastIndex(workspace, conf.PathSeparator)+1:] + " (" + + workspace + ")", + Path: workspacePath, IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}} + + walk(workspacePath, &workspaceNode) + + // 添加工作空间节点 + root.FileNodes = append(root.FileNodes, &workspaceNode) + } // 构造 Go API 节点 apiPath := runtime.GOROOT() + conf.PathSeparator + "src" + conf.PathSeparator + "pkg" @@ -65,9 +80,6 @@ func GetFiles(w http.ResponseWriter, r *http.Request) { close(goapiBuildOKSignal) }() - // 构造用户工作空间文件树 - walk(userSrc, &root) - // 等待放行 <-goapiBuildOKSignal