Skip to content

Commit 917e31e

Browse files
authored
Merge pull request #4322 from Tyriar/4124
Explain object option edge case
2 parents 1c7c4eb + aba59e9 commit 917e31e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

typings/xterm.d.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,17 +712,30 @@ declare module 'xterm' {
712712
readonly modes: IModes;
713713

714714
/**
715-
* Gets or sets the terminal options. This supports setting multiple options.
715+
* Gets or sets the terminal options. This supports setting multiple
716+
* options.
716717
*
717718
* @example Get a single option
718719
* ```ts
719720
* console.log(terminal.options.fontSize);
720721
* ```
721722
*
722-
* @example Set a single option
723+
* @example Set a single option:
723724
* ```ts
724725
* terminal.options.fontSize = 12;
725726
* ```
727+
* Note that for options that are object, a new object must be used in order
728+
* to take effect as a reference comparison will be done:
729+
* ```ts
730+
* const newValue = terminal.options.theme;
731+
* newValue.background = '#000000';
732+
*
733+
* // This won't work
734+
* terminal.options.theme = newValue;
735+
*
736+
* // This will work
737+
* terminal.options.theme = { ...newValue };
738+
* ```
726739
*
727740
* @example Set multiple options
728741
* ```ts

0 commit comments

Comments
 (0)