As vscode-markdownlint behavior

Signed-off-by: Yukai Huang <yukaihuangtw@gmail.com>
This commit is contained in:
Yukai Huang 2021-01-26 12:52:48 +08:00
parent ad6f82c9f6
commit f2912efd25
No known key found for this signature in database
GPG Key ID: D4D3B2F0E99D4914
1 changed files with 37 additions and 29 deletions

View File

@ -29,12 +29,10 @@ require('script-loader!markdownlint');
}
return {
messageHTML: `${ruleNames.slice(0, 1)}: ${ruleDescription}`,
messageHTML: `${ruleNames.join('/')}: ${ruleDescription} <small>markdownlint(${ruleNames[0]})</small>`,
severity: 'error',
from: CodeMirror.Pos(lineNumber, start),
to: CodeMirror.Pos(lineNumber, end),
__ruleNames: ruleNames,
__ruleDescription: ruleDescription,
__error: error
}
})
@ -47,11 +45,13 @@ export const linterOptions = {
fixedTooltip: true,
contextmenu: annotations => {
const singleFixMenus = annotations
.filter(ann => ann.__error.fixInfo)
.map(annotation => {
const error = annotation.__error
const ruleNameAlias = error.ruleNames.join('/')
if (annotation.__error.fixInfo) {
return {
content: `Fix ${error.ruleDescription}`,
content: `Click to fix this violoation of ${ruleNameAlias}`,
onClick () {
const doc = window.editor.doc
const fixInfo = normalizeFixInfo(error.fixInfo, error.lineNumber)
@ -82,6 +82,14 @@ export const linterOptions = {
}
}
}
} else {
return {
content: `Click for more information about ${ruleNameAlias}`,
onClick () {
window.open(error.ruleInformation, '_blank')
}
}
}
})
return singleFixMenus