From 1b4718cf14aa9b4e31e97ce3deb50f2ce937b6aa Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 11 Sep 2017 12:27:20 +0300 Subject: [PATCH] FinInFiles panel crash fix #265 --- dub.json | 2 +- src/dlangide/ui/commands.d | 2 +- src/dlangide/ui/frame.d | 11 +++++++++-- src/dlangide/ui/searchPanel.d | 11 +++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/dub.json b/dub.json index 6b4af88..8b4edb8 100644 --- a/dub.json +++ b/dub.json @@ -12,7 +12,7 @@ "stringImportPaths": ["views", "views/res", "views/res/i18n", "views/res/mdpi", "views/res/hdpi"], "dependencies": { - "dlangui": "==0.9.120", + "dlangui": "==0.9.121", "dsymbol": "~>0.2.9", "dcd": "~>0.9.1" }, diff --git a/src/dlangide/ui/commands.d b/src/dlangide/ui/commands.d index dd11b17..f935b19 100644 --- a/src/dlangide/ui/commands.d +++ b/src/dlangide/ui/commands.d @@ -144,4 +144,4 @@ const Action ACTION_GO_TO_DEFINITION = (new Action(IDEActions.GoToDefinition, " const Action ACTION_GET_COMPLETIONS = (new Action(IDEActions.GetCompletionSuggestions, "SHOW_COMPLETIONS"c, ""c, KeyCode.KEY_G, KeyFlag.Control|KeyFlag.Shift)).addAccelerator(KeyCode.SPACE, KeyFlag.Control).disableByDefault(); const Action ACTION_GET_PAREN_COMPLETION = (new Action(IDEActions.GetParenCompletion, "SHOW_PAREN_COMPLETION"c, ""c, KeyCode.SPACE, KeyFlag.Control|KeyFlag.Shift)).disableByDefault(); -const Action ACTION_FIND_TEXT = (new Action(IDEActions.FindInFiles, "FIND_IN_FILES"c, "edit-find"c, KeyCode.KEY_F, KeyFlag.Control | KeyFlag.Shift)); +const Action ACTION_FIND_TEXT = (new Action(IDEActions.FindInFiles, "FIND_IN_FILES"c, "edit-find"c, KeyCode.KEY_F, KeyFlag.Control | KeyFlag.Shift)).disableByDefault(); diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index 7f50928..f3b8112 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -887,6 +887,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL else a.state = ACTION_STATE_DISABLE; return true; + case IDEActions.FindInFiles: + a.state = currentWorkspace !is null ? ACTION_STATE_ENABLED : ACTION_STATE_DISABLE; + return true; default: return super.handleActionStateRequest(a); } @@ -1094,8 +1097,12 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL setStartupProject(cast(Project)a.objectParam); return true; case IDEActions.FindInFiles: - Log.d("Opening Search Field"); - import dlangide.ui.searchPanel; + Log.d("Opening Search In Files panel"); + if (!currentWorkspace) { + Log.d("No workspace is opened"); + return true; + } + import dlangide.ui.searchPanel; int searchPanelIndex = _logPanel.getTabs.tabIndex("search"); SearchWidget searchPanel = null; if(searchPanelIndex == -1) { diff --git a/src/dlangide/ui/searchPanel.d b/src/dlangide/ui/searchPanel.d index 2d0d533..1ef7042 100644 --- a/src/dlangide/ui/searchPanel.d +++ b/src/dlangide/ui/searchPanel.d @@ -194,10 +194,11 @@ class SearchWidget : TabWidget { _layout = new HorizontalLayout(); _layout.addChild(new TextWidget("FindLabel", "Find: "d)); - + _layout.layoutWidth = FILL_PARENT; + _findText = new EditLine(); _findText.padding(Rect(5,4,50,4)); - _findText.layoutWidth(400); + _findText.layoutWidth = FILL_PARENT; _findText.editorAction = &onEditorAction; // to handle Enter key press in editor _layout.addChild(_findText); @@ -205,6 +206,8 @@ class SearchWidget : TabWidget { goButton.click = &onFindButtonPressed; _layout.addChild(goButton); + _layout.addChild(new HSpacer); + _searchScope = new ComboBox("searchScope", ["File"d, "Project"d, "Dependencies"d, "Everywhere"d]); _searchScope.selectedItemIndex = 0; _layout.addChild(_searchScope); @@ -257,6 +260,10 @@ class SearchWidget : TabWidget { _resultLog.setTextToHighlight(""d, 0); _resultLog.text = ""d; + + if (currentWorkspace is null) + return false; + _matchedList = []; _resultLogMatchIndex = 0;