Skip to content

Commit

Permalink
fix: block comment with full problems
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiaxuan committed Oct 29, 2022
1 parent 6250ad3 commit e6773dc
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ const disposes = [

activeTextEditor.selections.forEach(selection => {

if (!Object.keys(lineRuleIdsMap).some(problemLine =>
selection.start.line + 1 <= +problemLine && +problemLine <= selection.end.line + 1)) {
log('No problem rules found on selected lines.', true, 'OK')
return
}

const text = getTextBylines(selection.start.line, selection.end.line)
if (!text?.replace(/\n|\r/g, '')) {
log('No content to disable.', true, 'OK')
return
}

if (!Object.keys(lineRuleIdsMap).some(problemLine =>
selection.start.line + 1 <= +problemLine && +problemLine <= selection.end.line + 1)) {
log('No problem rules found on your selection.', true, 'OK')
return
}

let insertIndex = 0
while (text.charAt(insertIndex) == ' ') {
insertIndex++
Expand All @@ -130,7 +130,9 @@ const disposes = [

const ruleIDSet = new Set<string>()
for (const line in lineRuleIdsMap) {
lineRuleIdsMap[line].forEach(item => ruleIDSet.add(item))
if (selection.start.line + 1 <= +line && +line <= selection.end.line + 1) {
lineRuleIdsMap[line].forEach(item => ruleIDSet.add(item))
}
}

void activeTextEditor.insertSnippet(
Expand Down

0 comments on commit e6773dc

Please sign in to comment.