1919 *
2020 */
2121
22- /*global jsPromise*/
22+ /*global jsPromise, path */
2323
2424/**
2525 * Manages linters and other code inspections on a per-language basis. Provides a UI and status indicator for
@@ -347,8 +347,9 @@ define(function (require, exports, module) {
347347 * @param {Number } numProblems - total number of problems across all providers
348348 * @param {Array.<{name:string, scanFileAsync:?function(string, string):!{$.Promise}, scanFile:?function(string, string):Object}> } providersReportingProblems - providers that reported problems
349349 * @param {boolean } aborted - true if any provider returned a result with the 'aborted' flag set
350+ * @param fileName
350351 */
351- function updatePanelTitleAndStatusBar ( numProblems , providersReportingProblems , aborted ) {
352+ function updatePanelTitleAndStatusBar ( numProblems , providersReportingProblems , aborted , fileName ) {
352353 var message , tooltip ;
353354
354355 if ( providersReportingProblems . length === 1 ) {
@@ -357,13 +358,14 @@ define(function (require, exports, module) {
357358 $problemsPanelTable . find ( "tr" ) . removeClass ( "forced-hidden" ) ;
358359
359360 if ( numProblems === 1 && ! aborted ) {
360- message = StringUtils . format ( Strings . SINGLE_ERROR , providersReportingProblems [ 0 ] . name ) ;
361+ message = StringUtils . format ( Strings . SINGLE_ERROR , providersReportingProblems [ 0 ] . name , fileName ) ;
361362 } else {
362363 if ( aborted ) {
363364 numProblems += "+" ;
364365 }
365366
366- message = StringUtils . format ( Strings . MULTIPLE_ERRORS , providersReportingProblems [ 0 ] . name , numProblems ) ;
367+ message = StringUtils . format ( Strings . MULTIPLE_ERRORS , providersReportingProblems [ 0 ] . name , numProblems ,
368+ fileName ) ;
367369 }
368370 } else if ( providersReportingProblems . length > 1 ) {
369371 $problemsPanelTable . find ( ".inspector-section" ) . show ( ) ;
@@ -372,7 +374,7 @@ define(function (require, exports, module) {
372374 numProblems += "+" ;
373375 }
374376
375- message = StringUtils . format ( Strings . ERRORS_PANEL_TITLE_MULTIPLE , numProblems ) ;
377+ message = StringUtils . format ( Strings . ERRORS_PANEL_TITLE_MULTIPLE , numProblems , fileName ) ;
376378 } else {
377379 return ;
378380 }
@@ -570,7 +572,8 @@ define(function (require, exports, module) {
570572 } ) ;
571573 }
572574
573- let linterHadRun = false ;
575+ const scrollPositionMap = new Map ( ) ;
576+
574577 /**
575578 * Run inspector applicable to current document. Updates status bar indicator and refreshes error list in
576579 * bottom panel. Does not run if inspection is disabled or if a providerName is given and does not
@@ -598,21 +601,22 @@ define(function (require, exports, module) {
598601 return ! provider . canInspect || provider . canInspect ( currentDoc . file . fullPath ) ;
599602 } ) ;
600603
601- let editor = EditorManager . getCurrentFullEditor ( ) ;
604+ let editor = EditorManager . getCurrentFullEditor ( ) , fullFilePath ;
602605 if ( editor ) {
603606 lastDocumentScanTimeStamp = editor . document . lastChangeTimestamp ;
604607 documentFixes . clear ( ) ;
605608 editor . clearAllMarks ( CODE_MARK_TYPE_INSPECTOR ) ;
606609 editor . clearGutter ( CODE_INSPECTION_GUTTER ) ;
610+ fullFilePath = editor . document . file . fullPath ;
607611 }
608612
609613 if ( providerList && providerList . length ) {
610- var numProblems = 0 ;
611- var aborted = false ;
612- var allErrors = [ ] ;
613- var html ;
614- var providersReportingProblems = [ ] ;
615- $problemsPanelTable . empty ( ) ;
614+ let numProblems = 0 ,
615+ aborted = false ,
616+ allErrors = [ ] ,
617+ html ,
618+ providersReportingProblems = [ ] ;
619+ scrollPositionMap . set ( $problemsPanelTable . lintFilePath || fullFilePath , $problemsPanelTable . scrollTop ( ) ) ;
616620
617621 // run all the providers registered for this file type
618622 ( _currentPromise = inspectFile ( currentDoc . file , providerList ) ) . then ( function ( results ) {
@@ -688,16 +692,19 @@ define(function (require, exports, module) {
688692 // Update results table
689693 html = Mustache . render ( ResultsTemplate , { Strings : Strings , reportList : allErrors } ) ;
690694
695+ const scrollPosition = scrollPositionMap . get ( fullFilePath ) || 0 ;
696+ $problemsPanelTable . lintFilePath = fullFilePath ;
691697 $problemsPanelTable
692698 . empty ( )
693699 . append ( html )
694- . scrollTop ( 0 ) ; // otherwise scroll pos from previous contents is remembered
700+ . scrollTop ( scrollPosition ) ; // otherwise scroll pos from previous contents is remembered
695701
696702 if ( ! _collapsed ) {
697703 problemsPanel . show ( ) ;
698704 }
699705
700- updatePanelTitleAndStatusBar ( numProblems , providersReportingProblems , aborted ) ;
706+ updatePanelTitleAndStatusBar ( numProblems , providersReportingProblems , aborted ,
707+ path . basename ( fullFilePath ) ) ;
701708 setGotoEnabled ( true ) ;
702709
703710 PerfUtils . addMeasurement ( perfTimerDOM ) ;
@@ -707,7 +714,8 @@ define(function (require, exports, module) {
707714 // No provider for current file
708715 _hasErrors = false ;
709716 _currentPromise = null ;
710- updatePanelTitleAndStatusBar ( 0 , [ ] , false ) ;
717+ updatePanelTitleAndStatusBar ( 0 , [ ] , false ,
718+ fullFilePath ? path . basename ( fullFilePath ) : Strings . ERRORS_NO_FILE ) ;
711719 if ( problemsPanel ) {
712720 problemsPanel . hide ( ) ;
713721 }
@@ -846,6 +854,21 @@ define(function (require, exports, module) {
846854 run ( ) ;
847855 }
848856
857+ let lastRunTime ;
858+ $ ( window . document ) . on ( "mousemove" , ( ) => {
859+ const editor = EditorManager . getCurrentFullEditor ( ) ;
860+ if ( ! editor || editor . document . lastChangeTimestamp === lastDocumentScanTimeStamp ) {
861+ return ;
862+ }
863+ const currentTime = Date . now ( ) ;
864+ if ( lastRunTime && ( currentTime - lastRunTime ) < 1000 ) {
865+ // we dont run the linter on mouse operations more than 1 times a second.
866+ return ;
867+ }
868+ lastRunTime = currentTime ;
869+ run ( ) ;
870+ } ) ;
871+
849872 /**
850873 * Toggle the collapsed state for the panel. This explicitly collapses the panel (as opposed to
851874 * the auto collapse due to files with no errors & filetypes with no provider). When explicitly
0 commit comments