Skip to content

Commit a8c634d

Browse files
committed
Restore useText
1 parent 8bfdb41 commit a8c634d

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/server/scriptInfo.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ namespace ts.server {
6464
this.switchToScriptVersionCache();
6565
}
6666

67-
public useText_TestOnly(newText?: string) {
67+
/** Public for testing */
68+
public useText(newText?: string) {
6869
this.svc = undefined;
6970
this.text = newText;
7071
this.lineMap = undefined;
@@ -90,22 +91,13 @@ namespace ts.server {
9091
// Reload always has fresh content
9192
this.pendingReloadFromDisk = false;
9293

93-
// We only need both this.text and this.fileSize if this.text
94-
// is artificially empty because it was too large.
95-
// We assume that an empty string passed to reload is not
96-
// for a file that was too large to store.
97-
this.fileSize = undefined;
98-
9994
// If text changed set the text
10095
// This also ensures that if we had switched to version cache,
10196
// we are switching back to text.
10297
// The change to version cache will happen when needed
10398
// Thus avoiding the computation if there are no changes
10499
if (this.text !== newText) {
105-
this.text = newText;
106-
this.version.text++;
107-
this.svc = undefined;
108-
this.lineMap = undefined;
100+
this.useText(newText);
109101
// We cant guarantee new text is own file text
110102
this.ownFileText = false;
111103
return true;

src/testRunner/unittests/textStorage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ts.textStorage {
1818
const ts2 = new server.TextStorage(host, server.asNormalizedPath(f.path), /*initialVersion*/ undefined, /*info*/undefined!);
1919

2020
ts1.useScriptVersionCache_TestOnly();
21-
ts2.useText_TestOnly();
21+
ts2.useText();
2222

2323
const lineMap = computeLineStarts(f.content);
2424

@@ -57,7 +57,7 @@ namespace ts.textStorage {
5757
ts1.edit(0, 5, " ");
5858
assert.isTrue(ts1.hasScriptVersionCache_TestOnly(), "have script version cache - 1");
5959

60-
ts1.useText_TestOnly();
60+
ts1.useText();
6161
assert.isFalse(ts1.hasScriptVersionCache_TestOnly(), "should not have script version cache - 2");
6262

6363
ts1.getLineInfo(0);
@@ -77,7 +77,7 @@ namespace ts.textStorage {
7777
// Since script info is not used in these tests, just cheat by passing undefined
7878
const ts1 = new server.TextStorage(host, server.asNormalizedPath(f.path), /*initialVersion*/ undefined, /*info*/undefined!);
7979

80-
ts1.useText_TestOnly(f.content);
80+
ts1.useText(f.content);
8181
assert.isFalse(ts1.hasScriptVersionCache_TestOnly());
8282

8383
assert.strictEqual(f.content.length, ts1.getTelemetryFileSize());

0 commit comments

Comments
 (0)