From e6773dc1b8bd87c9b7b452680e49d734acf86e48 Mon Sep 17 00:00:00 2001 From: lvjiaxuan <471501748@qq.com> Date: Sat, 29 Oct 2022 17:34:31 +0800 Subject: [PATCH] fix: block comment with full problems --- src/extension.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index b9487a9..191b2bc 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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++ @@ -130,7 +130,9 @@ const disposes = [ const ruleIDSet = new Set() 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(