Skip to content

Commit d6443ff

Browse files
cull trimRange (#1898)
It is unused. I believe that it also contains a latent bug, when the range contains entirely whitespace. Noticed during discussion at #1854 (comment) ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 9730ac5 commit d6443ff

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

packages/cursorless-engine/src/util/rangeUtils.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Position, Range, TextEditor } from "@cursorless/common";
2-
import { getLeadingWhitespace, getTrailingWhitespace } from "./regex";
32

43
export function isAtEndOfLine(editor: TextEditor, position: Position) {
54
const endLine = editor.document.lineAt(position);
@@ -54,30 +53,3 @@ export function strictlyContains(
5453
: [rangeOrPosition.start, rangeOrPosition.end];
5554
return range1.start.isBefore(start) && range1.end.isAfter(end);
5655
}
57-
58-
/**
59-
* Trim the given range of whitespaces
60-
* @param editor The editor to get the text from
61-
* @param range The range to trim
62-
*/
63-
export function trimRange(editor: TextEditor, range: Range): Range {
64-
const text = editor.document.getText(range);
65-
const leadingWhitespace = getLeadingWhitespace(text);
66-
const trailingWhitespace = getTrailingWhitespace(text);
67-
68-
if (leadingWhitespace === "" && trailingWhitespace === "") {
69-
return range;
70-
}
71-
72-
const startOffset =
73-
editor.document.offsetAt(range.start) + leadingWhitespace.length;
74-
return new Range(
75-
editor.document.positionAt(startOffset),
76-
editor.document.positionAt(
77-
startOffset +
78-
text.length -
79-
leadingWhitespace.length -
80-
trailingWhitespace.length,
81-
),
82-
);
83-
}

0 commit comments

Comments
 (0)