diff --git a/packages/cursorless-engine/src/util/rangeUtils.ts b/packages/cursorless-engine/src/util/rangeUtils.ts index 33d5def915..89bf2aebd3 100644 --- a/packages/cursorless-engine/src/util/rangeUtils.ts +++ b/packages/cursorless-engine/src/util/rangeUtils.ts @@ -1,5 +1,4 @@ import { Position, Range, TextEditor } from "@cursorless/common"; -import { getLeadingWhitespace, getTrailingWhitespace } from "./regex"; export function isAtEndOfLine(editor: TextEditor, position: Position) { const endLine = editor.document.lineAt(position); @@ -54,30 +53,3 @@ export function strictlyContains( : [rangeOrPosition.start, rangeOrPosition.end]; return range1.start.isBefore(start) && range1.end.isAfter(end); } - -/** - * Trim the given range of whitespaces - * @param editor The editor to get the text from - * @param range The range to trim - */ -export function trimRange(editor: TextEditor, range: Range): Range { - const text = editor.document.getText(range); - const leadingWhitespace = getLeadingWhitespace(text); - const trailingWhitespace = getTrailingWhitespace(text); - - if (leadingWhitespace === "" && trailingWhitespace === "") { - return range; - } - - const startOffset = - editor.document.offsetAt(range.start) + leadingWhitespace.length; - return new Range( - editor.document.positionAt(startOffset), - editor.document.positionAt( - startOffset + - text.length - - leadingWhitespace.length - - trailingWhitespace.length, - ), - ); -}