Skip to content

Commit a8ead81

Browse files
committed
Move clarification into write apis
1 parent 9696dd0 commit a8ead81

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

typings/xterm-headless.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,8 @@ declare module '@xterm/headless' {
837837
* bytes given as Uint8Array from the pty or a string. Raw bytes will always
838838
* be treated as UTF-8 encoded, string data as UTF-16.
839839
* @param callback Optional callback that fires when the data was processed
840-
* by the parser.
840+
* by the parser. This callback must be provided and awaited in order for
841+
* {@link buffer} to reflect the change in the write.
841842
*/
842843
write(data: string | Uint8Array, callback?: () => void): void;
843844

@@ -847,7 +848,8 @@ declare module '@xterm/headless' {
847848
* bytes given as Uint8Array from the pty or a string. Raw bytes will always
848849
* be treated as UTF-8 encoded, string data as UTF-16.
849850
* @param callback Optional callback that fires when the data was processed
850-
* by the parser.
851+
* by the parser. This callback must be provided and awaited in order for
852+
* {@link buffer} to reflect the change in the write.
851853
*/
852854
writeln(data: string | Uint8Array, callback?: () => void): void;
853855

typings/xterm.d.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,18 +1166,7 @@ declare module '@xterm/xterm' {
11661166
deregisterCharacterJoiner(joinerId: number): void;
11671167

11681168
/**
1169-
* Adds a marker to the normal buffer and returns it.
1170-
* NOTE: If you are synchronously writing data line-by-line (as in, doing
1171-
* multiple `term.writeln()`before the terminal re-rendering), the cursorY
1172-
* position will not be updated until after all pending terminal writes,
1173-
* which will result in the markers offset being calculated from the
1174-
* position cursorY was when your batch of writes started.
1175-
* Dealing with this issue by setting `cursorYOffset` to be index of this
1176-
* line in your batch will fail if you have any line wraps prior to it.
1177-
* Instead, consider registering a marker inside a write callback, eg.:
1178-
* ```ts
1179-
* term.writeln(data, () => term.registerMarker(...))
1180-
* ```
1169+
* Adds a marker to the normal buffer and returns it.
11811170
* @param cursorYOffset The y position offset of the marker from the cursor.
11821171
* @returns The new marker or undefined.
11831172
*/
@@ -1280,7 +1269,8 @@ declare module '@xterm/xterm' {
12801269
* bytes given as Uint8Array from the pty or a string. Raw bytes will always
12811270
* be treated as UTF-8 encoded, string data as UTF-16.
12821271
* @param callback Optional callback that fires when the data was processed
1283-
* by the parser.
1272+
* by the parser. This callback must be provided and awaited in order for
1273+
* {@link buffer} to reflect the change in the write.
12841274
*/
12851275
write(data: string | Uint8Array, callback?: () => void): void;
12861276

@@ -1290,7 +1280,8 @@ declare module '@xterm/xterm' {
12901280
* bytes given as Uint8Array from the pty or a string. Raw bytes will always
12911281
* be treated as UTF-8 encoded, string data as UTF-16.
12921282
* @param callback Optional callback that fires when the data was processed
1293-
* by the parser.
1283+
* by the parser. This callback must be provided and awaited in order for
1284+
* {@link buffer} to reflect the change in the write.
12941285
*/
12951286
writeln(data: string | Uint8Array, callback?: () => void): void;
12961287

0 commit comments

Comments
 (0)