From 3dcac4fa4c4e8eb7b79ef7177853d8daead2aa92 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Dec 2024 10:23:40 +0100 Subject: [PATCH] More clean up --- .../getDelimiterOccurrences.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getDelimiterOccurrences.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getDelimiterOccurrences.ts index e0eedd0473..522c30b502 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getDelimiterOccurrences.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/getDelimiterOccurrences.ts @@ -38,15 +38,6 @@ export function getDelimiterOccurrences( ]), ); - const isDisqualified = (range: Range): boolean => { - const delimiter = disqualifyDelimitersIterator.getContaining(range); - return delimiter != null && !delimiter.hasError(); - }; - - const getTextFragmentRange = (range: Range): Range | undefined => { - return textFragmentsIterator.getContaining(range)?.range; - }; - const matchIterator = matchAllIterator( document.getText(), getDelimiterRegex(individualDelimiters), @@ -61,10 +52,13 @@ export function getDelimiterOccurrences( document.positionAt(match.index! + text.length), ); - if (!isDisqualified(range)) { + const delimiter = disqualifyDelimitersIterator.getContaining(range); + const isDisqualified = delimiter != null && !delimiter.hasError(); + + if (!isDisqualified) { results.push({ delimiterInfo: delimiterTextToDelimiterInfoMap[text], - textFragmentRange: getTextFragmentRange(range), + textFragmentRange: textFragmentsIterator.getContaining(range)?.range, range, }); }