@@ -386,9 +386,9 @@ define(function (require, exports, module) {
386386
387387 function _getMarkOptions ( error ) {
388388 switch ( error . type ) {
389- case Type . ERROR : return Editor . MARK_OPTION_UNDERLINE_ERROR ;
390- case Type . WARNING : return Editor . MARK_OPTION_UNDERLINE_WARN ;
391- case Type . META : return Editor . MARK_OPTION_UNDERLINE_INFO ;
389+ case Type . ERROR : return Editor . getMarkOptionUnderlineError ( ) ;
390+ case Type . WARNING : return Editor . getMarkOptionUnderlineWarn ( ) ;
391+ case Type . META : return Editor . getMarkOptionUnderlineInfo ( ) ;
392392 }
393393 }
394394
@@ -490,18 +490,47 @@ define(function (require, exports, module) {
490490 _populateDummyGutterElements ( editor , from , to ) ;
491491 }
492492
493+ function _scrollToTableLine ( lineNumber ) {
494+ const $lineElement = $problemsPanelTable . find ( 'td.line-number[data-line="' + lineNumber + '"]' ) ;
495+ if ( $lineElement . length ) {
496+ $lineElement [ 0 ] . scrollIntoView ( { behavior : 'instant' , block : 'start' } ) ;
497+ }
498+ }
499+
500+
493501 function getQuickView ( editor , pos , token , line ) {
494502 return new Promise ( ( resolve , reject ) => {
495503 let codeInspectionMarks = editor . findMarksAt ( pos , CODE_MARK_TYPE_INSPECTOR ) || [ ] ;
496- let hoverMessage = '' ;
504+ let $hoverMessage = $ ( `<div class="code-inspection-item"></div>` ) ;
505+ let $problemView , quickViewPresent ;
497506 for ( let mark of codeInspectionMarks ) {
498- hoverMessage = `${ hoverMessage } ${ mark . message } <br/>` ;
507+ quickViewPresent = true ;
508+ const fixID = `${ mark . metadata } ` ;
509+ if ( documentFixes . get ( fixID ) ) {
510+ $problemView = $ ( `<div>
511+ <button class="btn btn-mini primary fix-problem-btn" style="margin-right: 5px;">Fix</button>
512+ ${ mark . message } <br/>
513+ </div>` ) ;
514+ $problemView . find ( ".fix-problem-btn" ) . click ( ( ) => {
515+ _scrollToTableLine ( pos . line ) ;
516+ _fixProblem ( fixID ) ;
517+ } ) ;
518+ $hoverMessage . append ( $problemView ) ;
519+ } else {
520+ $problemView = $ ( `<div>${ mark . message } <br/></div>` ) ;
521+ $hoverMessage . append ( $problemView ) ;
522+ }
523+ // eslint-disable-next-line no-loop-func
524+ $problemView . click ( function ( ) {
525+ toggleCollapsed ( false ) ;
526+ _scrollToTableLine ( pos . line ) ;
527+ } ) ;
499528 }
500- if ( hoverMessage ) {
529+ if ( quickViewPresent ) {
501530 resolve ( {
502- start : { line : pos . line , ch : token . start } ,
531+ start : { line : pos . line , ch : token . start } , // tod this should not be of the token
503532 end : { line : pos . line , ch : token . end } ,
504- content : `<div class="code-inspection-item"> ${ hoverMessage } </div>`
533+ content : $ hoverMessage
505534 } ) ;
506535 return ;
507536 }
@@ -941,6 +970,21 @@ define(function (require, exports, module) {
941970 description : Strings . DESCRIPTION_USE_PREFERED_ONLY
942971 } ) ;
943972
973+ function _fixProblem ( fixID ) {
974+ const fixDetails = documentFixes . get ( fixID ) ;
975+ const editor = EditorManager . getCurrentFullEditor ( ) ;
976+ if ( ! editor || ! fixDetails || editor . document . lastChangeTimestamp !== lastDocumentScanTimeStamp ) {
977+ Dialogs . showErrorDialog ( Strings . CANNOT_FIX_TITLE , Strings . CANNOT_FIX_MESSAGE ) ;
978+ } else {
979+ const from = editor . posFromIndex ( fixDetails . rangeOffset . start ) ,
980+ to = editor . posFromIndex ( fixDetails . rangeOffset . end ) ;
981+ editor . setSelection ( from , to , true , Editor . BOUNDARY_BULLSEYE , EDIT_ORIGIN_LINT_FIX ) ;
982+ editor . replaceSelection ( fixDetails . replaceText , "around" ) ;
983+ }
984+ MainViewManager . focusActivePane ( ) ;
985+ run ( ) ;
986+ }
987+
944988 // Initialize items dependent on HTML DOM
945989 AppInit . htmlReady ( function ( ) {
946990 Editor . registerGutter ( CODE_INSPECTION_GUTTER , CODE_INSPECTION_GUTTER_PRIORITY ) ;
@@ -974,21 +1018,9 @@ define(function (require, exports, module) {
9741018 }
9751019 if ( $ ( e . target ) . hasClass ( 'ph-fix-problem' ) ) {
9761020 // Retrieve the message from the data attribute of the clicked element
977- const fixid = "" + $ ( e . target ) . data ( "fixid" ) ;
978- const fixDetails = documentFixes . get ( fixid ) ;
979- const editor = EditorManager . getCurrentFullEditor ( ) ;
980- if ( ! editor || ! fixDetails || editor . document . lastChangeTimestamp !== lastDocumentScanTimeStamp ) {
981- Dialogs . showErrorDialog ( Strings . CANNOT_FIX_TITLE , Strings . CANNOT_FIX_MESSAGE ) ;
982- } else {
983- const from = editor . posFromIndex ( fixDetails . rangeOffset . start ) ,
984- to = editor . posFromIndex ( fixDetails . rangeOffset . end ) ;
985- editor . setSelection ( from , to , true , Editor . BOUNDARY_BULLSEYE , EDIT_ORIGIN_LINT_FIX ) ;
986- editor . replaceSelection ( fixDetails . replaceText , "around" ) ;
987- }
1021+ _fixProblem ( "" + $ ( e . target ) . data ( "fixid" ) ) ;
9881022 e . preventDefault ( ) ;
9891023 e . stopPropagation ( ) ;
990- MainViewManager . focusActivePane ( ) ;
991- run ( ) ;
9921024 return ;
9931025 }
9941026
0 commit comments