@@ -92,17 +92,24 @@ define(function (require, exports, module) {
9292 configID,
9393 config : projectSpecificOptions
9494 } ) . then ( lintResult => {
95- const editor = EditorManager . getCurrentFullEditor ( ) ;
95+ let editor = EditorManager . getCurrentFullEditor ( ) ;
9696 if ( ! editor || editor . document . file . fullPath !== fullPath ) {
97- reject ( new Error ( "Lint failed as " + ProjectManager . getProjectRelativeOrDisplayPath ( fullPath )
98- + " is not active." ) ) ;
99- return ;
97+ // this is not the active editor the lint is about. so the html validate api sends the startPos of
98+ // the error, but doesn't send the end pos, instead it sends the end offset. We need end line:ch pos
99+ //to highlight error properly, and computing that needs an editor(or we need to impl that logic)
100+ // so for now, we use the active editor if there is one to properly underline errors, and if we
101+ // cant find the active editor, we will do an approximation on the current line
102+ editor = null ;
100103 }
101104 if ( lintResult && lintResult . length ) {
102105 lintResult = lintResult . map ( function ( lintError ) {
103106 return {
104- pos : editor . posFromIndex ( lintError . start ) ,
105- endPos : editor . posFromIndex ( lintError . end ) ,
107+ pos : editor ? editor . posFromIndex ( lintError . start ) : lintError . startPos ,
108+ endPos : editor ? editor . posFromIndex ( lintError . end ) : {
109+ line : lintError . startPos . line ,
110+ // highlightOffset can span multiple lines, so this is at best an approximation
111+ ch : lintError . startPos . ch + lintError . highlightOffset
112+ } ,
106113 message : `${ lintError . message } (${ lintError . ruleId } )` ,
107114 type : getTypeFromSeverity ( lintError . severity ) ,
108115 moreInfoURL : lintError . ruleUrl
0 commit comments