@@ -97,6 +97,13 @@ define(function (require, exports, module) {
9797 */
9898 var _gotoEnabled = false ;
9999
100+ /**
101+ * @private
102+ * @type {boolean }
103+ */
104+ var _hasErrors = false ;
105+
106+
100107 /**
101108 * Enable or disable the "Go to First JSLint Error" command
102109 * @param {boolean } gotoEnabled Whether it is enabled.
@@ -139,8 +146,10 @@ define(function (require, exports, module) {
139146 perfTimerDOM = PerfUtils . markStart ( "JSLint DOM:\t" + ( ! currentDoc || currentDoc . file . fullPath ) ) ;
140147
141148 if ( ! result ) {
142- // Remove the null errors for the template
149+ // Remove any null error (early-abort indicator) before rendering results
143150 var errors = JSLINT . errors . filter ( function ( err ) { return err !== null ; } ) ;
151+
152+ // Update results table
144153 var html = Mustache . render ( ResultsTemplate , { reportList : errors } ) ;
145154 var $selectedRow ;
146155
@@ -164,16 +173,16 @@ define(function (require, exports, module) {
164173 EditorManager . focusEditor ( ) ;
165174 } ) ;
166175
176+ _hasErrors = true ;
167177 if ( ! _collapsed ) {
168178 Resizer . show ( $lintResults ) ;
169179 }
170180 if ( JSLINT . errors . length === 1 ) {
171181 StatusBar . updateIndicator ( INDICATOR_ID , true , "jslint-errors" , Strings . JSLINT_ERROR_INFORMATION ) ;
172182 } else {
173- // Return the number of non-null errors
183+ // Error count string: if we filtered out a null above, there was a stop error so the
184+ // total number of errors is indeterminate. Append a '+' to indicate that.
174185 var numberOfErrors = errors . length ;
175- // If there was a null value it means there was a stop notice and an indeterminate
176- // upper bound on the number of JSLint errors, which we'll represent by appending a '+'
177186 if ( numberOfErrors !== JSLINT . errors . length ) {
178187 // First discard the stop notice
179188 numberOfErrors -= 1 ;
@@ -185,6 +194,7 @@ define(function (require, exports, module) {
185194 setGotoEnabled ( true ) ;
186195
187196 } else {
197+ _hasErrors = false ;
188198 Resizer . hide ( $lintResults ) ;
189199 StatusBar . updateIndicator ( INDICATOR_ID , true , "jslint-valid" , Strings . JSLINT_NO_ERRORS ) ;
190200 setGotoEnabled ( false ) ;
@@ -194,6 +204,7 @@ define(function (require, exports, module) {
194204
195205 } else {
196206 // JSLint is disabled or does not apply to the current file, hide the results
207+ _hasErrors = false ;
197208 Resizer . hide ( $lintResults ) ;
198209 StatusBar . updateIndicator ( INDICATOR_ID , true , "jslint-disabled" , Strings . JSLINT_DISABLED ) ;
199210 setGotoEnabled ( false ) ;
@@ -291,29 +302,34 @@ define(function (require, exports, module) {
291302 AppInit . htmlReady ( function ( ) {
292303 ExtensionUtils . loadStyleSheet ( module , "jslint.css" ) ;
293304
305+ // Create bottom panel to list error details
294306 var jsLintHtml = Mustache . render ( JSLintTemplate , Strings ) ;
295307 var resultsPanel = PanelManager . createBottomPanel ( "jslint.results" , $ ( jsLintHtml ) , 100 ) ;
296308 $lintResults = $ ( "#jslint-results" ) ;
297309
298310 var lintStatusHtml = Mustache . render ( "<div id=\"lint-status\" title=\"{{JSLINT_NO_ERRORS}}\"> </div>" , Strings ) ;
299311 $ ( lintStatusHtml ) . insertBefore ( "#status-language" ) ;
300- StatusBar . addIndicator ( INDICATOR_ID , $ ( "#lint-status" ) ) ;
301312 $ ( "#jslint-results .close" ) . click ( function ( ) {
302313 toggleCollapsed ( true ) ;
303314 } ) ;
315+
316+ // Create status bar indicator
317+ StatusBar . addIndicator ( INDICATOR_ID , $ ( "#lint-status" ) ) ;
304318
305- $ ( "#jslint-status" ) . click ( function ( ) {
306- toggleCollapsed ( ) ;
319+ $ ( "#jslint-status" ) . click ( function ( event ) {
320+ // Clicking indicator toggles error panel, if any errors in current file
321+ if ( _hasErrors ) {
322+ toggleCollapsed ( ) ;
323+ }
307324 } ) ;
308-
309-
310- // Called on HTML ready to trigger the initial UI state
325+
326+ // Set initial UI state
311327 setEnabled ( _prefs . getValue ( "enabled" ) ) ;
312328
313329 toggleCollapsed ( _prefs . getValue ( "collapsed" ) ) ;
314-
315330 } ) ;
316331
332+
317333 // for unit tests
318334 exports . setEnabled = setEnabled ;
319335} ) ;
0 commit comments