Skip to content

Commit 3444a91

Browse files
felixlheureuxFélix L'Heureux
andauthored
Reset value to an empty string when undefined or null (microsoft#165721)
* Reset value to an empty string * Throw illegalArgument instead of setting the value as '' Co-authored-by: Félix L'Heureux <[email protected]>
1 parent 8df188a commit 3444a91

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/vs/editor/common/model/textModel.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { ArrayQueue, pushMany } from 'vs/base/common/arrays';
77
import { VSBuffer, VSBufferReadableStream } from 'vs/base/common/buffer';
88
import { Color } from 'vs/base/common/color';
9-
import { onUnexpectedError } from 'vs/base/common/errors';
9+
import { illegalArgument, onUnexpectedError } from 'vs/base/common/errors';
1010
import { Emitter, Event } from 'vs/base/common/event';
1111
import { IMarkdownString } from 'vs/base/common/htmlContent';
1212
import { combinedDisposable, Disposable, IDisposable } from 'vs/base/common/lifecycle';
@@ -429,9 +429,9 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati
429429

430430
public setValue(value: string | model.ITextSnapshot): void {
431431
this._assertNotDisposed();
432-
if (value === null) {
433-
// There's nothing to do
434-
return;
432+
433+
if (value === null || value === undefined) {
434+
throw illegalArgument();
435435
}
436436

437437
const { textBuffer, disposable } = createTextBuffer(value, this._options.defaultEOL);

0 commit comments

Comments
 (0)