Skip to content

Commit 7c5d170

Browse files
committed
Only show the error console automatically on the first error in the project (#80) (#90)
1 parent 5b5fba3 commit 7c5d170

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/com/intellij/lang/jsgraphql/ide/project/JSGraphQLLanguageUIProjectService.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ public class JSGraphQLLanguageUIProjectService implements Disposable, FileEditor
114114
public final static String GRAPH_QL_TOOL_WINDOW_NAME = "GraphQL";
115115
public static final String GRAPH_QL_VARIABLES_JSON = "GraphQL.variables.json";
116116

117+
private static final Key<Boolean> JSGRAPHQL_SHOW_CONSOLE_ON_ERROR = Key.create("JSGraphQL.showConsoleOnError");
118+
117119
/**
118120
* Indicates that this virtual file backs a GraphQL variables editor
119121
*/
@@ -195,6 +197,15 @@ public static JSGraphQLLanguageUIProjectService getService(@NotNull Project proj
195197
return ServiceManager.getService(project, JSGraphQLLanguageUIProjectService.class);
196198
}
197199

200+
public static void showErrorConsole(@NotNull Project project) {
201+
final Boolean showConsoleOnError = project.getUserData(JSGRAPHQL_SHOW_CONSOLE_ON_ERROR);
202+
if(!Boolean.FALSE.equals(showConsoleOnError)) {
203+
// only show the console automatically on the first error in the project
204+
showToolWindowContent(project, ConsoleView.class);
205+
project.putUserData(JSGRAPHQL_SHOW_CONSOLE_ON_ERROR, false);
206+
}
207+
}
208+
198209
public static void showConsole(@NotNull Project project) {
199210
showToolWindowContent(project, ConsoleView.class);
200211
}
@@ -232,7 +243,7 @@ public void onTextAvailable(ProcessEvent event, Key outputType) {
232243
if(StringUtils.isNotEmpty(event.getText())) {
233244
if (outputType == ProcessOutputTypes.STDERR) {
234245
// show the console on errors during initialization
235-
showConsole(myProject);
246+
showErrorConsole(myProject);
236247
}
237248
}
238249
}

src/main/com/intellij/lang/jsgraphql/languageservice/JSGraphQLNodeLanguageServiceInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public void onTextAvailable(ProcessEvent event, Key outputType) {
288288
} else if(outputType == ProcessOutputTypes.STDERR) {
289289
result.set(false);
290290
countDownLatch.countDown();
291-
JSGraphQLLanguageUIProjectService.showConsole(project);
291+
JSGraphQLLanguageUIProjectService.showErrorConsole(project);
292292
}
293293
}
294294
}

0 commit comments

Comments
 (0)