-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathVscodeTextLine.ts
More file actions
40 lines (33 loc) · 1.02 KB
/
Copy pathVscodeTextLine.ts
File metadata and controls
40 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type * as vscode from "vscode";
import type { TextLine } from "@cursorless/lib-common";
import { Position, Range } from "@cursorless/lib-common";
import { fromVscodeRange } from "@cursorless/lib-vscode-common";
export class VscodeTextLine implements TextLine {
constructor(private line: vscode.TextLine) {}
get lineNumber(): number {
return this.line.lineNumber;
}
get text(): string {
return this.line.text;
}
get range(): Range {
return fromVscodeRange(this.line.range);
}
get rangeIncludingLineBreak(): Range {
return fromVscodeRange(this.line.rangeIncludingLineBreak);
}
get rangeTrimmed(): Range | undefined {
return this.line.isEmptyOrWhitespace
? undefined
: new Range(
new Position(
this.lineNumber,
this.line.firstNonWhitespaceCharacterIndex,
),
new Position(this.lineNumber, this.line.text.trimEnd().length),
);
}
get isEmptyOrWhitespace(): boolean {
return this.line.isEmptyOrWhitespace;
}
}