Skip to content

Commit 2511dcc

Browse files
devvaannshabose
authored andcommitted
feat: dont auto show problems panel
1 parent bd5993e commit 2511dcc

1 file changed

Lines changed: 40 additions & 74 deletions

File tree

src/language/CodeInspection.js

Lines changed: 40 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ define(function (require, exports, module) {
111111
* @private
112112
*/
113113
const PREF_ENABLED = "enabled",
114-
PREF_COLLAPSED = "collapsed",
115114
PREF_ASYNC_TIMEOUT = "asyncTimeout",
116115
PREF_PREFER_PROVIDERS = "prefer",
117116
PREF_PREFERRED_ONLY = "usePreferredOnly";
@@ -120,19 +119,11 @@ define(function (require, exports, module) {
120119

121120
/**
122121
* When disabled, the errors panel is closed and the status bar icon is grayed out.
123-
* Takes precedence over _collapsed.
124122
* @private
125123
* @type {boolean}
126124
*/
127125
var _enabled = false;
128126

129-
/**
130-
* When collapsed, the errors panel is closed but the status bar icon is kept up to date.
131-
* @private
132-
* @type {boolean}
133-
*/
134-
var _collapsed = false;
135-
136127
/**
137128
* @private
138129
* @type {$.Element}
@@ -467,7 +458,7 @@ define(function (require, exports, module) {
467458
.addClass(CODE_INSPECTION_GUTTER);
468459
$marker.click(function (){
469460
editor.setCursorPos(line, ch);
470-
toggleCollapsed(false);
461+
_showProblemsPanel();
471462
scrollToProblem(line);
472463
});
473464
$marker.find('span')
@@ -601,7 +592,7 @@ define(function (require, exports, module) {
601592
// shouldnt open the problems panel
602593
return;
603594
}
604-
toggleCollapsed(false);
595+
_showProblemsPanel();
605596
scrollToProblem(pos.line);
606597
// todo strobe effect
607598
});
@@ -711,21 +702,24 @@ define(function (require, exports, module) {
711702
const scrollPositionMap = new Map();
712703

713704
function _noProviderReturnedResults(currentDoc, fullFilePath) {
714-
// No provider for current file
705+
// No provider for current file — update content but never hide the panel.
715706
_hasErrors = false;
716707
_currentPromise = null;
717-
updatePanelTitleAndStatusBar(0, [], false,
718-
fullFilePath ? path.basename(fullFilePath) : Strings.ERRORS_NO_FILE);
719-
if(problemsPanel){
720-
problemsPanel.hide();
721-
}
708+
709+
let message;
722710
const language = currentDoc && LanguageManager.getLanguageForPath(currentDoc.file.fullPath);
723711
if (language) {
724-
StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-disabled",
725-
StringUtils.format(Strings.NO_LINT_AVAILABLE, language.getName()));
712+
message = StringUtils.format(Strings.NO_LINT_AVAILABLE, language.getName());
726713
} else {
727-
StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-disabled", Strings.NOTHING_TO_LINT);
714+
message = Strings.NOTHING_TO_LINT;
728715
}
716+
717+
// Update panel content to show the "no linter" message
718+
$problemsPanel.find(".title").text(message);
719+
$problemsPanelTable.empty();
720+
$fixAllBtn.addClass("forced-hidden");
721+
722+
StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-disabled", message);
729723
setGotoEnabled(false);
730724
}
731725

@@ -742,7 +736,11 @@ define(function (require, exports, module) {
742736
if (!_enabled) {
743737
_hasErrors = false;
744738
_currentPromise = null;
745-
problemsPanel.hide();
739+
// Update status bar to show linting is disabled, but do NOT hide the panel.
740+
// The panel content will be cleared and the status bar updated.
741+
$problemsPanel.find(".title").text(Strings.LINT_DISABLED);
742+
$problemsPanelTable.empty();
743+
$fixAllBtn.addClass("forced-hidden");
746744
StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-disabled", Strings.LINT_DISABLED);
747745
setGotoEnabled(false);
748746
return;
@@ -794,13 +792,16 @@ define(function (require, exports, module) {
794792
_hasErrors = Boolean(errors);
795793

796794
if (!errors) {
797-
problemsPanel.hide();
798-
795+
// No errors found — update panel content but never hide the panel.
799796
var message = Strings.NO_ERRORS_MULTIPLE_PROVIDER;
800797
if (providerList.length === 1) {
801798
message = StringUtils.format(Strings.NO_ERRORS, providerList[0].name);
802799
}
803800

801+
$problemsPanel.find(".title").text(message);
802+
$problemsPanelTable.empty();
803+
$fixAllBtn.addClass("forced-hidden");
804+
804805
StatusBar.updateIndicator(INDICATOR_ID, true, "inspection-valid", message);
805806

806807
setGotoEnabled(false);
@@ -859,10 +860,6 @@ define(function (require, exports, module) {
859860
.empty()
860861
.append(html); // otherwise scroll pos from previous contents is remembered
861862

862-
if (!_collapsed) {
863-
problemsPanel.show();
864-
}
865-
866863
updatePanelTitleAndStatusBar(numProblems, providersReportingProblems, aborted,
867864
path.basename(fullFilePath));
868865
setGotoEnabled(true);
@@ -1038,7 +1035,14 @@ define(function (require, exports, module) {
10381035
}
10391036

10401037
function toggleProblems() {
1041-
toggleCollapsed();
1038+
if (!problemsPanel) {
1039+
return;
1040+
}
1041+
if (problemsPanel.isVisible()) {
1042+
problemsPanel.hide();
1043+
} else {
1044+
problemsPanel.show();
1045+
}
10421046
}
10431047

10441048
let lastRunTime;
@@ -1060,34 +1064,14 @@ define(function (require, exports, module) {
10601064
});
10611065

10621066
/**
1063-
* Toggle the collapsed state for the panel. This explicitly collapses the panel (as opposed to
1064-
* the auto collapse due to files with no errors & filetypes with no provider). When explicitly
1065-
* collapsed, the panel will not reopen automatically on switch files or save.
1067+
* Show the problems panel. Used by gutter marker clicks and QuickView
1068+
* clicks to ensure the panel is visible when the user interacts with
1069+
* an error indicator.
10661070
* @private
1067-
* @param {?boolean} collapsed Collapsed state. If omitted, the state is toggled.
1068-
* @param {?boolean} doNotSave true if the preference should not be saved to user settings. This is generally for events triggered by project-level settings.
10691071
*/
1070-
function toggleCollapsed(collapsed, doNotSave) {
1071-
if (collapsed === undefined) {
1072-
collapsed = !_collapsed;
1073-
}
1074-
1075-
if (collapsed === _collapsed) {
1076-
return;
1077-
}
1078-
1079-
_collapsed = collapsed;
1080-
if (!doNotSave) {
1081-
prefs.set(PREF_COLLAPSED, _collapsed);
1082-
prefs.save();
1083-
}
1084-
1085-
if (_collapsed) {
1086-
problemsPanel.hide();
1087-
} else {
1088-
if (_hasErrors) {
1089-
problemsPanel.show();
1090-
}
1072+
function _showProblemsPanel() {
1073+
if (problemsPanel && !problemsPanel.isVisible()) {
1074+
problemsPanel.show();
10911075
}
10921076
}
10931077

@@ -1183,13 +1167,6 @@ define(function (require, exports, module) {
11831167
toggleEnabled(prefs.get(PREF_ENABLED), true);
11841168
});
11851169

1186-
prefs.definePreference(PREF_COLLAPSED, "boolean", false, {
1187-
description: Strings.DESCRIPTION_LINTING_COLLAPSED
1188-
})
1189-
.on("change", function (e, data) {
1190-
toggleCollapsed(prefs.get(PREF_COLLAPSED), true);
1191-
});
1192-
11931170
prefs.definePreference(PREF_ASYNC_TIMEOUT, "number", 10000, {
11941171
description: Strings.DESCRIPTION_ASYNC_TIMEOUT
11951172
});
@@ -1359,23 +1336,12 @@ define(function (require, exports, module) {
13591336
StatusBar.addIndicator(INDICATOR_ID, $(statusIconHtml), true, "", "", "status-indent");
13601337

13611338
$("#status-inspection").click(function () {
1362-
// Clicking indicator toggles error panel, if any errors in current file
1363-
if (_hasErrors) {
1364-
toggleCollapsed();
1365-
}
1366-
});
1367-
1368-
// When the panel tab is closed externally (e.g. via the × button),
1369-
// update the collapsed state so the panel doesn't auto-reopen.
1370-
WorkspaceManager.on(WorkspaceManager.EVENT_WORKSPACE_PANEL_HIDDEN, function (event, panelID) {
1371-
if (panelID === "errors") {
1372-
_collapsed = true;
1373-
}
1339+
// Clicking indicator always toggles the problems panel
1340+
toggleProblems();
13741341
});
13751342

13761343
// Set initial UI state
13771344
toggleEnabled(prefs.get(PREF_ENABLED), true);
1378-
toggleCollapsed(prefs.get(PREF_COLLAPSED), true);
13791345

13801346
QuickViewManager.registerQuickViewProvider({
13811347
getQuickView,

0 commit comments

Comments
 (0)