File tree Expand file tree Collapse file tree 1 file changed +0
-28
lines changed
packages/cursorless-engine/src/util Expand file tree Collapse file tree 1 file changed +0
-28
lines changed Original file line number Diff line number Diff line change 11import { Position , Range , TextEditor } from "@cursorless/common" ;
2- import { getLeadingWhitespace , getTrailingWhitespace } from "./regex" ;
32
43export 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- }
You can’t perform that action at this time.
0 commit comments