MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / TextEdit

Class TextEdit

packages/vscode-shim/src/classes/TextEdit.ts:31–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 * ```
30 */
31export class TextEdit {
32 /**
33 * The range to replace
34 */
35 public readonly range: Range
36
37 /**
38 * The new text (empty string for deletion)
39 */
40 public readonly newText: string
41
42 /**
43 * Create a new TextEdit
44 *
45 * @param range - The range to replace
46 * @param newText - The new text
47 */
48 constructor(range: IRange, newText: string) {
49 this.range = range as Range
50 this.newText = newText
51 }
52
53 /**
54 * Create a replace edit
55 *
56 * @param range - The range to replace
57 * @param newText - The new text
58 * @returns A new TextEdit
59 */
60 static replace(range: IRange, newText: string): TextEdit {
61 return new TextEdit(range, newText)
62 }
63
64 /**
65 * Create an insert edit
66 *
67 * @param position - The position to insert at
68 * @param newText - The text to insert
69 * @returns A new TextEdit
70 */
71 static insert(position: IPosition, newText: string): TextEdit {
72 return new TextEdit(new Range(position, position), newText)
73 }
74
75 /**
76 * Create a delete edit
77 *
78 * @param range - The range to delete
79 * @returns A new TextEdit
80 */
81 static delete(range: IRange): TextEdit {
82 return new TextEdit(range, "")
83 }
84
85 /**
86 * Create an edit to set the end of line sequence
87 *
88 * @returns A new TextEdit (simplified implementation)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected