diff --git a/src/services/pasteEdits.ts b/src/services/pasteEdits.ts
index e39a51bf45076..d3c84b118aa8e 100644
--- a/src/services/pasteEdits.ts
+++ b/src/services/pasteEdits.ts
@@ -3,12 +3,17 @@ import {
codefix,
Debug,
fileShouldUseJavaScriptRequire,
+ findAncestor,
findIndex,
forEachChild,
formatting,
+ getNewLineOrDefaultFromHost,
getQuotePreference,
+ getTokenAtPosition,
isIdentifier,
Program,
+ rangeContainsPosition,
+ rangeContainsRange,
SourceFile,
Statement,
SymbolFlags,
@@ -56,17 +61,16 @@ function pasteEdits(
cancellationToken: CancellationToken,
changes: textChanges.ChangeTracker,
) {
- let actualPastedText: string[] | undefined;
+ let actualPastedText: string | undefined;
if (pastedText.length !== pasteLocations.length) {
- actualPastedText = pastedText.length === 1 ? pastedText : [pastedText.join("\n")];
+ actualPastedText = pastedText.length === 1 ? pastedText[0] : pastedText.join(getNewLineOrDefaultFromHost(formatContext.host, formatContext.options));
}
const statements: Statement[] = [];
-
let newText = targetFile.text;
for (let i = pasteLocations.length - 1; i >= 0; i--) {
const { pos, end } = pasteLocations[i];
- newText = actualPastedText ? newText.slice(0, pos) + actualPastedText[0] + newText.slice(end) : newText.slice(0, pos) + pastedText[i] + newText.slice(end);
+ newText = actualPastedText ? newText.slice(0, pos) + actualPastedText + newText.slice(end) : newText.slice(0, pos) + pastedText[i] + newText.slice(end);
}
let importAdder: codefix.ImportAdder;
@@ -104,12 +108,46 @@ function pasteEdits(
preferences,
formatContext,
};
- forEachChild(updatedFile, function cb(node) {
- if (isIdentifier(node) && !originalProgram?.getTypeChecker().resolveName(node.text, node, SymbolFlags.All, /*excludeGlobals*/ false)) {
- // generate imports
- importAdder.addImportForUnresolvedIdentifier(context, node, /*useAutoImportProvider*/ true);
- }
- node.forEachChild(cb);
+
+ // `updatedRanges` represent the new ranges that account for the offset changes caused by pasting new text and
+ // `offset` represents by how much the starting position of `pasteLocations` needs to be changed.
+ //
+ // We iterate over each updated range to get the node that wholly encloses the updated range.
+ // For each child of that node, we checked for unresolved identifiers
+ // within the updated range and try importing it.
+ let offset = 0;
+ pasteLocations.forEach((location, i) => {
+ const oldTextLength = location.end - location.pos;
+ const textToBePasted = actualPastedText ?? pastedText[i];
+ const startPos = location.pos + offset;
+ const endPos = startPos + textToBePasted.length;
+ const range: TextRange = { pos: startPos, end: endPos };
+ offset += textToBePasted.length - oldTextLength;
+
+ const enclosingNode = findAncestor(
+ getTokenAtPosition(context.sourceFile, range.pos),
+ ancestorNode => rangeContainsRange(ancestorNode, range),
+ );
+ if (!enclosingNode) return;
+
+ forEachChild(enclosingNode, function importUnresolvedIdentifiers(node) {
+ const isImportCandidate = isIdentifier(node) &&
+ rangeContainsPosition(range, node.getStart(updatedFile)) &&
+ !updatedProgram?.getTypeChecker().resolveName(
+ node.text,
+ node,
+ SymbolFlags.All,
+ /*excludeGlobals*/ false,
+ );
+ if (isImportCandidate) {
+ return importAdder.addImportForUnresolvedIdentifier(
+ context,
+ node,
+ /*useAutoImportProvider*/ true,
+ );
+ }
+ node.forEachChild(importUnresolvedIdentifiers);
+ });
});
}
importAdder.writeFixes(changes, getQuotePreference(copiedFrom ? copiedFrom.file : targetFile, preferences));
@@ -125,8 +163,7 @@ function pasteEdits(
changes.replaceRangeWithText(
targetFile,
{ pos: paste.pos, end: paste.end },
- actualPastedText ?
- actualPastedText[0] : pastedText[i],
+ actualPastedText ?? pastedText[i],
);
});
}
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesConsistentlyLargerInSize.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesConsistentlyLargerInSize.js
new file mode 100644
index 0000000000000..78ab9b41c0ac3
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesConsistentlyLargerInSize.js
@@ -0,0 +1,396 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+function foo() {
+ const p = 1;
+ console.log("yes");
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log("have a good day");
+ }
+ a();
+ function b() {
+ function c() {
+ const test = 1 + 2 + 3;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const happy = banana + avocados;
+ }
+ }
+}
+
+//// [/b.ts]
+export const juice = 1;
+export const sauce = 2;
+export const fig = 3;
+export const tomato = 4;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 "function foo() {\n const p = 1;\n console.log(\"yes\");\n}\nclass bar {\n constructor() {\n function a() {\n console.log(\"have a good day\");\n }\n a();\n function b() {\n function c() {\n const test = 1 + 2 + 3;\n } \n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const happy = banana + avocados;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const fig = 3;\nexport const tomato = 4;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "const t = 1 + juice + p;",
+ "function avacado() { return sauce; }",
+ "fig + kiwi",
+ "function k() {\n const cherry = 3 + tomato + cucumber;\n }"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 3,
+ "offset": 4
+ },
+ "end": {
+ "line": 3,
+ "offset": 23
+ }
+ },
+ {
+ "start": {
+ "line": 8,
+ "offset": 13
+ },
+ "end": {
+ "line": 8,
+ "offset": 44
+ }
+ },
+ {
+ "start": {
+ "line": 13,
+ "offset": 29
+ },
+ "end": {
+ "line": 13,
+ "offset": 34
+ }
+ },
+ {
+ "start": {
+ "line": 20,
+ "offset": 9
+ },
+ "end": {
+ "line": 22,
+ "offset": 10
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "function foo() {\n const p = 1;\n const t = 1 + juice + p;\n}\nclass bar {\n constructor() {\n function a() {\n function avacado() { return sauce; }\n }\n a();\n function b() {\n function c() {\n const test = fig + kiwi + 3;\n } \n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const cherry = 3 + tomato + cucumber;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const fig = 3;\nexport const tomato = 4;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [
+ {
+ "fileName": "/a.ts",
+ "textChanges": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ },
+ "newText": "import { juice, sauce, fig, tomato } from \"./b\";\n\n"
+ },
+ {
+ "start": {
+ "line": 3,
+ "offset": 4
+ },
+ "end": {
+ "line": 3,
+ "offset": 23
+ },
+ "newText": "const t = 1 + juice + p;"
+ },
+ {
+ "start": {
+ "line": 8,
+ "offset": 13
+ },
+ "end": {
+ "line": 8,
+ "offset": 44
+ },
+ "newText": "function avacado() { return sauce; }"
+ },
+ {
+ "start": {
+ "line": 13,
+ "offset": 29
+ },
+ "end": {
+ "line": 13,
+ "offset": 34
+ },
+ "newText": "fig + kiwi"
+ },
+ {
+ "start": {
+ "line": 20,
+ "offset": 9
+ },
+ "end": {
+ "line": 22,
+ "offset": 10
+ },
+ "newText": "function k() {\n const cherry = 3 + tomato + cucumber;\n }"
+ }
+ ]
+ }
+ ],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesConsistentlySmallerInSize.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesConsistentlySmallerInSize.js
new file mode 100644
index 0000000000000..bf2203d796453
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesConsistentlySmallerInSize.js
@@ -0,0 +1,403 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+function foo() {
+ const p = 1;
+ function bar() {
+ console.log("Testing");
+ }
+ console.log("yes");
+}
+class bar {
+ constructor() {
+ function a() {
+ function aa() {
+ console.log("have a good day");
+ }
+
+ }
+ a();
+ function b() {
+ function c() {
+ export const testing = 1;
+ const test = 1 + testing + 3;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const happy = banana + avocados;
+ }
+ }
+}
+
+//// [/b.ts]
+export const juice = 1;
+export const sauce = 2;
+export const fig = 3;
+export const tomato = 4;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 "function foo() {\n const p = 1;\n function bar() {\n console.log(\"Testing\");\n }\n console.log(\"yes\");\n}\nclass bar {\n constructor() {\n function a() {\n function aa() {\n console.log(\"have a good day\");\n }\n \n }\n a();\n function b() {\n function c() {\n export const testing = 1;\n const test = 1 + testing + 3;\n }\n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const happy = banana + avocados;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const fig = 3;\nexport const tomato = 4;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "juice",
+ "sole.log(sauce + juice);",
+ "fig + kiwi",
+ "function k() {\n const cherry =tomato + kiwi;\n }"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 4,
+ "offset": 20
+ },
+ "end": {
+ "line": 4,
+ "offset": 29
+ }
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 19
+ },
+ "end": {
+ "line": 12,
+ "offset": 47
+ }
+ },
+ {
+ "start": {
+ "line": 20,
+ "offset": 29
+ },
+ "end": {
+ "line": 20,
+ "offset": 43
+ }
+ },
+ {
+ "start": {
+ "line": 27,
+ "offset": 9
+ },
+ "end": {
+ "line": 29,
+ "offset": 10
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "function foo() {\n const p = 1;\n function bar() {\n console.log(juice);\n }\n console.log(\"yes\");\n}\nclass bar {\n constructor() {\n function a() {\n function aa() {\n console.log(sauce + juice);\n }\n \n }\n a();\n function b() {\n function c() {\n export const testing = 1;\n const test = fig + kiwi3;\n }\n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const cherry =tomato + kiwi;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const fig = 3;\nexport const tomato = 4;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [
+ {
+ "fileName": "/a.ts",
+ "textChanges": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ },
+ "newText": "import { sauce, juice, fig, tomato } from \"./b\";\n\n"
+ },
+ {
+ "start": {
+ "line": 4,
+ "offset": 20
+ },
+ "end": {
+ "line": 4,
+ "offset": 29
+ },
+ "newText": "juice"
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 19
+ },
+ "end": {
+ "line": 12,
+ "offset": 47
+ },
+ "newText": "sole.log(sauce + juice);"
+ },
+ {
+ "start": {
+ "line": 20,
+ "offset": 29
+ },
+ "end": {
+ "line": 20,
+ "offset": 43
+ },
+ "newText": "fig + kiwi"
+ },
+ {
+ "start": {
+ "line": 27,
+ "offset": 9
+ },
+ "end": {
+ "line": 29,
+ "offset": 10
+ },
+ "newText": "function k() {\n const cherry =tomato + kiwi;\n }"
+ }
+ ]
+ }
+ ],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesEqualInSize.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesEqualInSize.js
new file mode 100644
index 0000000000000..0a98e82e17d6a
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesEqualInSize.js
@@ -0,0 +1,395 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+function foo() {
+ console.log("yes");
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log("have a good day");
+ }
+ a();
+ function b() {
+ function c() {
+ const test = 1 + 2 + 3;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const happy = 1 + banana + avocados;
+ }
+ }
+}
+
+//// [/b.ts]
+export const juice = 1;
+export const sauce = 2;
+export const apple = 3;
+export const tomato = 4;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 "function foo() {\n console.log(\"yes\");\n}\nclass bar {\n constructor() {\n function a() {\n console.log(\"have a good day\");\n }\n a();\n function b() {\n function c() {\n const test = 1 + 2 + 3;\n }\n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const happy = 1 + banana + avocados;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const apple = 3;\nexport const tomato = 4;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "console.log(juice);",
+ "function kl() { return sauce; }",
+ "apple",
+ "function k() {\n const cherry = 3 + tomato + cucumber;\n }"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 2,
+ "offset": 5
+ },
+ "end": {
+ "line": 2,
+ "offset": 24
+ }
+ },
+ {
+ "start": {
+ "line": 7,
+ "offset": 13
+ },
+ "end": {
+ "line": 7,
+ "offset": 44
+ }
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 29
+ },
+ "end": {
+ "line": 12,
+ "offset": 34
+ }
+ },
+ {
+ "start": {
+ "line": 19,
+ "offset": 9
+ },
+ "end": {
+ "line": 21,
+ "offset": 10
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "function foo() {\n console.log(juice);\n}\nclass bar {\n constructor() {\n function a() {\n function kl() { return sauce; }\n }\n a();\n function b() {\n function c() {\n const test = apple + 3;\n }\n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const cherry = 3 + tomato + cucumber;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const apple = 3;\nexport const tomato = 4;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [
+ {
+ "fileName": "/a.ts",
+ "textChanges": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ },
+ "newText": "import { juice, sauce, tomato } from \"./b\";\n\n"
+ },
+ {
+ "start": {
+ "line": 2,
+ "offset": 5
+ },
+ "end": {
+ "line": 2,
+ "offset": 24
+ },
+ "newText": "console.log(juice);"
+ },
+ {
+ "start": {
+ "line": 7,
+ "offset": 13
+ },
+ "end": {
+ "line": 7,
+ "offset": 44
+ },
+ "newText": "function kl() { return sauce; }"
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 29
+ },
+ "end": {
+ "line": 12,
+ "offset": 34
+ },
+ "newText": "apple"
+ },
+ {
+ "start": {
+ "line": 19,
+ "offset": 9
+ },
+ "end": {
+ "line": 21,
+ "offset": 10
+ },
+ "newText": "function k() {\n const cherry = 3 + tomato + cucumber;\n }"
+ }
+ ]
+ }
+ ],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesGrowingAndShrinkingInSize.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesGrowingAndShrinkingInSize.js
new file mode 100644
index 0000000000000..3ff982d88d1f0
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesGrowingAndShrinkingInSize.js
@@ -0,0 +1,392 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+function foo() {
+ console.log("Hello");
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log("hii");
+ }
+ a();
+ function b() {
+ function c() {
+ console.log("hola");
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+
+ }
+}
+
+//// [/b.ts]
+export const juice = 1;
+export const sauce = 2;
+export const tomato = 3;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 "function foo() {\n console.log(\"Hello\");\n}\nclass bar {\n constructor() {\n function a() {\n console.log(\"hii\");\n }\n a();\n function b() {\n function c() {\n console.log(\"hola\");\n }\n }\n b();\n }\n c() {\n console.log(\"hello again\");\n \n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const tomato = 3;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "log(sauce);",
+ "const apple = 1 + juice",
+ "const kiwi = 1;",
+ "function k() {\n const cherry = 3 + tomato + cucumber;\n }"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 2,
+ "offset": 13
+ },
+ "end": {
+ "line": 2,
+ "offset": 26
+ }
+ },
+ {
+ "start": {
+ "line": 5,
+ "offset": 5
+ },
+ "end": {
+ "line": 5,
+ "offset": 12
+ }
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 16
+ },
+ "end": {
+ "line": 12,
+ "offset": 36
+ }
+ },
+ {
+ "start": {
+ "line": 19,
+ "offset": 9
+ },
+ "end": {
+ "line": 19,
+ "offset": 9
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "function foo() {\n console.log(sauce);\n}\nclass bar {\n const apple = 1 + juicector() {\n function a() {\n console.log(\"hii\");\n }\n a();\n function b() {\n function c() {\n const kiwi = 1;\n }\n }\n b();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const cherry = 3 + tomato + cucumber;\n }\n }\n}"
+ /b.ts Text-1 "export const juice = 1;\nexport const sauce = 2;\nexport const tomato = 3;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [
+ {
+ "fileName": "/a.ts",
+ "textChanges": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ },
+ "newText": "import { sauce, tomato } from \"./b\";\n\n"
+ },
+ {
+ "start": {
+ "line": 2,
+ "offset": 13
+ },
+ "end": {
+ "line": 2,
+ "offset": 26
+ },
+ "newText": "log(sauce);"
+ },
+ {
+ "start": {
+ "line": 5,
+ "offset": 5
+ },
+ "end": {
+ "line": 5,
+ "offset": 12
+ },
+ "newText": "const apple = 1 + juice"
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 16
+ },
+ "end": {
+ "line": 12,
+ "offset": 36
+ },
+ "newText": "const kiwi = 1;"
+ },
+ {
+ "start": {
+ "line": 19,
+ "offset": 9
+ },
+ "end": {
+ "line": 19,
+ "offset": 9
+ },
+ "newText": "function k() {\n const cherry = 3 + tomato + cucumber;\n }"
+ }
+ ]
+ }
+ ],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesGrowingInSize.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesGrowingInSize.js
new file mode 100644
index 0000000000000..b73c74561d734
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesGrowingInSize.js
@@ -0,0 +1,412 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+function foo() {
+ const p = 1;
+}
+function too() {
+ function k(t: string) {
+ console.log(t);
+ }
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log("hello");
+ }
+ a();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const happy = banana + avocados;
+ }
+ }
+}
+
+//// [/b.ts]
+export const juices = 1;
+export const sauce = 2;
+
+//// [/c.ts]
+export const figs = 3;
+export const tomato = 4;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts", "c.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts",
+ "/c.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /c.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (6)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 "function foo() {\n const p = 1;\n}\nfunction too() {\n function k(t: string) {\n console.log(t);\n }\n}\nclass bar {\n constructor() {\n function a() {\n console.log(\"hello\");\n }\n a();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const happy = banana + avocados;\n }\n }\n}"
+ /b.ts Text-1 "export const juices = 1;\nexport const sauce = 2;"
+ /c.ts Text-1 "export const figs = 3;\nexport const tomato = 4;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+ c.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (6)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/c.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/c.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "const t = figs;",
+ "apples : number",
+ " console.log(sauce + tomato); ",
+ "//function k(i:string) {\n const cherry = 3 + juices + cucumber;\n// }"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 2,
+ "offset": 4
+ },
+ "end": {
+ "line": 2,
+ "offset": 16
+ }
+ },
+ {
+ "start": {
+ "line": 5,
+ "offset": 15
+ },
+ "end": {
+ "line": 5,
+ "offset": 24
+ }
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 1
+ },
+ "end": {
+ "line": 12,
+ "offset": 34
+ }
+ },
+ {
+ "start": {
+ "line": 18,
+ "offset": 9
+ },
+ "end": {
+ "line": 20,
+ "offset": 10
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (6)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "function foo() {\n const t = figs;\n}\nfunction too() {\n function k(apples : number) {\n console.log(t);\n }\n}\nclass bar {\n constructor() {\n function a() {\n console.log(sauce + tomato); \n }\n a();\n }\n c() {\n console.log(\"hello again\");\n //function k(i:string) {\n const cherry = 3 + juices + cucumber;\n// }\n }\n}"
+ /b.ts Text-1 "export const juices = 1;\nexport const sauce = 2;"
+ /c.ts Text-1 "export const figs = 3;\nexport const tomato = 4;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [
+ {
+ "fileName": "/a.ts",
+ "textChanges": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ },
+ "newText": "import { sauce, juices } from \"./b\";\nimport { figs, tomato } from \"./c\";\n\n"
+ },
+ {
+ "start": {
+ "line": 2,
+ "offset": 4
+ },
+ "end": {
+ "line": 2,
+ "offset": 16
+ },
+ "newText": "const t = figs;"
+ },
+ {
+ "start": {
+ "line": 5,
+ "offset": 15
+ },
+ "end": {
+ "line": 5,
+ "offset": 24
+ },
+ "newText": "apples : number"
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 1
+ },
+ "end": {
+ "line": 12,
+ "offset": 34
+ },
+ "newText": " console.log(sauce + tomato); "
+ },
+ {
+ "start": {
+ "line": 18,
+ "offset": 9
+ },
+ "end": {
+ "line": 20,
+ "offset": 10
+ },
+ "newText": "//function k(i:string) {\n const cherry = 3 + juices + cucumber;\n// }"
+ }
+ ]
+ }
+ ],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/c.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesShrinkingInSize.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesShrinkingInSize.js
new file mode 100644
index 0000000000000..0f1ad0b71e624
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_multiplePastesShrinkingInSize.js
@@ -0,0 +1,412 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+function foo() {
+ console.log("Good day");
+}
+function too() {
+ function k(t: string) {
+ console.log("Happy Holidays");
+ }
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log("hello");
+ }
+ a();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const happy = banana + avocados;
+ }
+ }
+}
+
+//// [/b.ts]
+export const juices = 1;
+export const sauce = 2;
+
+//// [/c.ts]
+export const figs = 3;
+export const tomato = 4;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts", "c.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts",
+ "/c.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /c.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (6)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 "function foo() {\n console.log(\"Good day\");\n}\nfunction too() {\n function k(t: string) {\n console.log(\"Happy Holidays\");\n }\n}\nclass bar {\n constructor() {\n function a() {\n console.log(\"hello\");\n }\n a();\n }\n c() {\n console.log(\"hello again\");\n function k() {\n const happy = banana + avocados;\n }\n }\n}"
+ /b.ts Text-1 "export const juices = 1;\nexport const sauce = 2;"
+ /c.ts Text-1 "export const figs = 3;\nexport const tomato = 4;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+ c.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (6)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/c.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/c.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "console.log(\"Good \");",
+ "const k = figs + juices;",
+ " console.log(tomato);",
+ "(kiwi: string) {\n const cherry=tomato;\n }"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 2,
+ "offset": 4
+ },
+ "end": {
+ "line": 2,
+ "offset": 28
+ }
+ },
+ {
+ "start": {
+ "line": 6,
+ "offset": 8
+ },
+ "end": {
+ "line": 6,
+ "offset": 38
+ }
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 1
+ },
+ "end": {
+ "line": 12,
+ "offset": 34
+ }
+ },
+ {
+ "start": {
+ "line": 18,
+ "offset": 19
+ },
+ "end": {
+ "line": 20,
+ "offset": 10
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (6)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "function foo() {\n console.log(\"Good \");\n}\nfunction too() {\n function k(t: string) {\n const k = figs + juices;\n }\n}\nclass bar {\n constructor() {\n function a() {\n console.log(tomato);\n }\n a();\n }\n c() {\n console.log(\"hello again\");\n function k(kiwi: string) {\n const cherry=tomato;\n }\n }\n}"
+ /b.ts Text-1 "export const juices = 1;\nexport const sauce = 2;"
+ /c.ts Text-1 "export const figs = 3;\nexport const tomato = 4;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [
+ {
+ "fileName": "/a.ts",
+ "textChanges": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ },
+ "newText": "import { juices } from \"./b\";\nimport { figs, tomato } from \"./c\";\n\n"
+ },
+ {
+ "start": {
+ "line": 2,
+ "offset": 4
+ },
+ "end": {
+ "line": 2,
+ "offset": 28
+ },
+ "newText": "console.log(\"Good \");"
+ },
+ {
+ "start": {
+ "line": 6,
+ "offset": 8
+ },
+ "end": {
+ "line": 6,
+ "offset": 38
+ },
+ "newText": "const k = figs + juices;"
+ },
+ {
+ "start": {
+ "line": 12,
+ "offset": 1
+ },
+ "end": {
+ "line": 12,
+ "offset": 34
+ },
+ "newText": " console.log(tomato);"
+ },
+ {
+ "start": {
+ "line": 18,
+ "offset": 19
+ },
+ "end": {
+ "line": 20,
+ "offset": 10
+ },
+ "newText": "(kiwi: string) {\n const cherry=tomato;\n }"
+ }
+ ]
+ }
+ ],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/c.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_noImportNeededInUpdatedProgram.js b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_noImportNeededInUpdatedProgram.js
new file mode 100644
index 0000000000000..8737891440e7c
--- /dev/null
+++ b/tests/baselines/reference/tsserver/fourslashServer/pasteEdits_noImportNeededInUpdatedProgram.js
@@ -0,0 +1,276 @@
+currentDirectory:: / useCaseSensitiveFileNames: false
+Info seq [hh:mm:ss:mss] Provided types map file "/typesMap.json" doesn't exist
+//// [/a.ts]
+
+
+//// [/b.ts]
+export const b = 10;
+
+//// [/lib.d.ts]
+lib.d.ts-Text
+
+//// [/lib.decorators.d.ts]
+lib.decorators.d.ts-Text
+
+//// [/lib.decorators.legacy.d.ts]
+lib.decorators.legacy.d.ts-Text
+
+//// [/tsconfig.json]
+{ "files": ["a.ts", "b.ts"] }
+
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 0,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts"
+ },
+ "command": "open"
+ }
+Info seq [hh:mm:ss:mss] getConfigFileNameForFile:: File: /a.ts ProjectRootPath: undefined:: Result: /tsconfig.json
+Info seq [hh:mm:ss:mss] Creating configuration project /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /tsconfig.json 2000 undefined Project: /tsconfig.json WatchType: Config file
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingStart",
+ "body": {
+ "projectName": "/tsconfig.json",
+ "reason": "Creating possible configured project for /a.ts to open"
+ }
+ }
+Info seq [hh:mm:ss:mss] Config: /tsconfig.json : {
+ "rootNames": [
+ "/a.ts",
+ "/b.ts"
+ ],
+ "options": {
+ "configFilePath": "/tsconfig.json"
+ }
+}
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /b.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] FileWatcher:: Added:: WatchInfo: /lib.decorators.legacy.d.ts 500 undefined WatchType: Closed Script info
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-0 ""
+ /b.ts Text-1 "export const b = 10;"
+
+
+ lib.d.ts
+ Default library for target 'es5'
+ lib.decorators.d.ts
+ Library referenced via 'decorators' from file 'lib.d.ts'
+ lib.decorators.legacy.d.ts
+ Library referenced via 'decorators.legacy' from file 'lib.d.ts'
+ a.ts
+ Part of 'files' list in tsconfig.json
+ b.ts
+ Part of 'files' list in tsconfig.json
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "projectLoadingFinish",
+ "body": {
+ "projectName": "/tsconfig.json"
+ }
+ }
+Info seq [hh:mm:ss:mss] event:
+ {
+ "seq": 0,
+ "type": "event",
+ "event": "configFileDiag",
+ "body": {
+ "triggerFile": "/a.ts",
+ "configFile": "/tsconfig.json",
+ "diagnostics": []
+ }
+ }
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] Open files:
+Info seq [hh:mm:ss:mss] FileName: /a.ts ProjectRootPath: undefined
+Info seq [hh:mm:ss:mss] Projects: /tsconfig.json
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "open",
+ "request_seq": 0,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ }
+ }
+After Request
+watchedFiles::
+/b.ts: *new*
+ {"pollingInterval":500}
+/lib.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.d.ts: *new*
+ {"pollingInterval":500}
+/lib.decorators.legacy.d.ts: *new*
+ {"pollingInterval":500}
+/tsconfig.json: *new*
+ {"pollingInterval":2000}
+
+Projects::
+/tsconfig.json (Configured) *new*
+ projectStateVersion: 1
+ projectProgramVersion: 1
+
+ScriptInfos::
+/a.ts (Open) *new*
+ version: SVC-1-0
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts *new*
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 1,
+ "type": "request",
+ "arguments": {
+ "formatOptions": {
+ "indentSize": 4,
+ "tabSize": 4,
+ "newLineCharacter": "\n",
+ "convertTabsToSpaces": true,
+ "indentStyle": 2,
+ "insertSpaceAfterConstructor": false,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
+ "insertSpaceBeforeFunctionParenthesis": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false,
+ "semicolons": "ignore",
+ "trimTrailingWhitespace": true,
+ "indentSwitchCase": true
+ }
+ },
+ "command": "configure"
+ }
+Info seq [hh:mm:ss:mss] Format host information updated
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "configure",
+ "request_seq": 1,
+ "success": true
+ }
+Info seq [hh:mm:ss:mss] request:
+ {
+ "seq": 2,
+ "type": "request",
+ "arguments": {
+ "file": "/a.ts",
+ "pastedText": [
+ "const b = 1;\nconsole.log(b);"
+ ],
+ "pasteLocations": [
+ {
+ "start": {
+ "line": 1,
+ "offset": 1
+ },
+ "end": {
+ "line": 1,
+ "offset": 1
+ }
+ }
+ ]
+ },
+ "command": "getPasteEdits"
+ }
+Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /tsconfig.json
+Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
+Info seq [hh:mm:ss:mss] Project '/tsconfig.json' (Configured)
+Info seq [hh:mm:ss:mss] Files (5)
+ /lib.d.ts Text-1 lib.d.ts-Text
+ /lib.decorators.d.ts Text-1 lib.decorators.d.ts-Text
+ /lib.decorators.legacy.d.ts Text-1 lib.decorators.legacy.d.ts-Text
+ /a.ts SVC-1-1 "const b = 1;\nconsole.log(b);"
+ /b.ts Text-1 "export const b = 10;"
+
+Info seq [hh:mm:ss:mss] -----------------------------------------------
+Info seq [hh:mm:ss:mss] response:
+ {
+ "seq": 0,
+ "type": "response",
+ "command": "getPasteEdits",
+ "request_seq": 2,
+ "success": true,
+ "performanceData": {
+ "updateGraphDurationMs": *
+ },
+ "body": {
+ "edits": [],
+ "fixId": "providePostPasteEdits"
+ }
+ }
+After Request
+Projects::
+/tsconfig.json (Configured) *changed*
+ projectStateVersion: 3 *changed*
+ projectProgramVersion: 1
+ dirty: true *changed*
+
+ScriptInfos::
+/a.ts (Open) *changed*
+ version: SVC-1-2 *changed*
+ containingProjects: 1
+ /tsconfig.json *default*
+/b.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
+/lib.decorators.legacy.d.ts
+ version: Text-1
+ containingProjects: 1
+ /tsconfig.json
diff --git a/tests/cases/fourslash/server/pasteEdits_addInNextLine.ts b/tests/cases/fourslash/server/pasteEdits_addInNextLine.ts
index ce3919b85c3f3..293840d052d10 100644
--- a/tests/cases/fourslash/server/pasteEdits_addInNextLine.ts
+++ b/tests/cases/fourslash/server/pasteEdits_addInNextLine.ts
@@ -18,12 +18,12 @@
// @Filename: /tsconfig.json
////{ "files": ["a.ts", "b.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [`export const foo: Foo = {};`],
- pasteLocations: [range[0]],
- copiedFrom: { file: "b.ts", range: [range[1]] },
+ pasteLocations: [ranges[0]],
+ copiedFrom: { file: "b.ts", range: [ranges[1]] },
},
newFileContents: {
"/a.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_blankTargetFile.ts b/tests/cases/fourslash/server/pasteEdits_blankTargetFile.ts
index d4fd49c285960..f9361a4163d10 100644
--- a/tests/cases/fourslash/server/pasteEdits_blankTargetFile.ts
+++ b/tests/cases/fourslash/server/pasteEdits_blankTargetFile.ts
@@ -17,12 +17,12 @@
// @Filename: /tsconfig.json
////{ "files": ["c.ts", "a.ts", "b.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [`console.log(abc);`],
- pasteLocations: [range[0]],
- copiedFrom: { file: "b.ts", range: [range[1]] },
+ pasteLocations: [ranges[0]],
+ copiedFrom: { file: "b.ts", range: [ranges[1]] },
},
newFileContents: {
"/c.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_existingImports1.ts b/tests/cases/fourslash/server/pasteEdits_existingImports1.ts
index 204d6bb0c8186..8141d9230d68d 100644
--- a/tests/cases/fourslash/server/pasteEdits_existingImports1.ts
+++ b/tests/cases/fourslash/server/pasteEdits_existingImports1.ts
@@ -19,11 +19,10 @@
// @Filename: /tsconfig.json
////{ "files": ["target.ts", "other.ts", "other2.ts", "other3.ts"] }
-const range = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `const m = t3 + t2 + 1;`],
- pasteLocations: [range[0]],
+ pasteLocations: test.ranges(),
},
newFileContents: {
"/target.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_existingImports2.ts b/tests/cases/fourslash/server/pasteEdits_existingImports2.ts
index e12fe6350dbc0..d27ffb415609c 100644
--- a/tests/cases/fourslash/server/pasteEdits_existingImports2.ts
+++ b/tests/cases/fourslash/server/pasteEdits_existingImports2.ts
@@ -25,12 +25,12 @@
// @Filename: /tsconfig.json
////{ "files": ["target.ts", "originalFile.ts", "other.ts", "other2.ts", "other3.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `const m = t3 + t2 + n;` ],
- pasteLocations: [range[0]],
- copiedFrom: { file: "originalFile.ts", range: [range[1]] },
+ pasteLocations: [ranges[0]],
+ copiedFrom: { file: "originalFile.ts", range: [ranges[1]] },
},
newFileContents: {
"/target.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_knownSourceFile.ts b/tests/cases/fourslash/server/pasteEdits_knownSourceFile.ts
index fe9023647fb0a..eb66aad510909 100644
--- a/tests/cases/fourslash/server/pasteEdits_knownSourceFile.ts
+++ b/tests/cases/fourslash/server/pasteEdits_knownSourceFile.ts
@@ -17,14 +17,13 @@
// @Filename: /tsconfig.json
////{ "files": ["file1.ts", "file2.ts", "target.ts"] }
-const range = test.ranges();
-const t = range[0];
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `const c = a + b;
const t = 9;`],
- pasteLocations: [range[0]],
- copiedFrom: { file: "file2.ts", range: [range[1]] },
+ pasteLocations: [ranges[0]],
+ copiedFrom: { file: "file2.ts", range: [ranges[1]] },
},
newFileContents: {
"/file2.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastes1.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastes1.ts
index 5b0e9f5bfbfdb..4751a721a412c 100644
--- a/tests/cases/fourslash/server/pasteEdits_multiplePastes1.ts
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastes1.ts
@@ -19,13 +19,13 @@
// @Filename: /tsconfig.json
////{ "files": ["file1.ts", "target.ts", "file3.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `const g = p + q;
function e();
const f = r + s;`],
- pasteLocations: [range[0], range[1]],
+ pasteLocations: [ranges[0], ranges[1]],
},
newFileContents: {
"/target.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastes2.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastes2.ts
index 71de5ac278f4e..4c46fc7413323 100644
--- a/tests/cases/fourslash/server/pasteEdits_multiplePastes2.ts
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastes2.ts
@@ -21,13 +21,13 @@
// @Filename: /tsconfig.json
////{ "files": ["file1.ts", "target.ts", "other.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `export const t = aa + bb + r + s;
const u = 1;`,],
- pasteLocations: [range[0], range[1]],
- copiedFrom: { file: "file1.ts", range: [range[2]] },
+ pasteLocations: [ranges[0], ranges[1]],
+ copiedFrom: { file: "file1.ts", range: [ranges[2]] },
},
newFileContents: {
"/target.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastes3.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastes3.ts
index 99b5451eb319f..f5233e9396576 100644
--- a/tests/cases/fourslash/server/pasteEdits_multiplePastes3.ts
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastes3.ts
@@ -24,13 +24,13 @@
// @Filename: /tsconfig.json
////{ "files": ["file1.ts", "target.ts", "other.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `export const t = aa + bb + r + s;
const u = 1;`, `export const k = r + m;`],
- pasteLocations: [range[0], range[1]],
- copiedFrom: { file: "file1.ts", range: [range[2], range[3]] },
+ pasteLocations: [ranges[0], ranges[1]],
+ copiedFrom: { file: "file1.ts", range: [ranges[2], ranges[3]] },
},
newFileContents: {
"/file1.ts":`import { aa, bb } from "./other";
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastes4.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastes4.ts
index 61d25803abd3d..84ed288aa4840 100644
--- a/tests/cases/fourslash/server/pasteEdits_multiplePastes4.ts
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastes4.ts
@@ -19,11 +19,11 @@
// @Filename: /tsconfig.json
////{ "files": ["file1.ts", "target.ts", "file3.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ "const g = p + q;", "const f = r + s;"],
- pasteLocations: [range[0], range[1], range[2]],
+ pasteLocations: [ranges[0], ranges[1], ranges[2]],
},
newFileContents: {
"/target.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlyLargerInSize.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlyLargerInSize.ts
new file mode 100644
index 0000000000000..5d0a825ddeb2c
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlyLargerInSize.ts
@@ -0,0 +1,78 @@
+///
+
+// @Filename: /a.ts
+//// function foo() {
+//// const p = 1;
+//// [|console.log("yes");|]
+//// }
+//// class bar {
+//// constructor() {
+//// function a() {
+//// [|console.log("have a good day");|]
+//// }
+//// a();
+//// function b() {
+//// function c() {
+//// const test = [|1 + 2|] + 3;
+//// }
+//// }
+//// b();
+//// }
+//// c() {
+//// console.log("hello again");
+//// [|function k() {
+//// const happy = banana + avocados;
+//// }|]
+//// }
+//// }
+
+// @Filename: /b.ts
+//// export const juice = 1;
+//// export const sauce = 2;
+//// export const fig = 3;
+//// export const tomato = 4;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `const t = 1 + juice + p;`,`function avacado() { return sauce; }`,
+ `fig + kiwi`,
+ `function k() {
+ const cherry = 3 + tomato + cucumber;
+ }`
+ ],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {
+ "/a.ts":
+`import { juice, sauce, fig, tomato } from "./b";
+
+function foo() {
+ const p = 1;
+ const t = 1 + juice + p;
+}
+class bar {
+ constructor() {
+ function a() {
+ function avacado() { return sauce; }
+ }
+ a();
+ function b() {
+ function c() {
+ const test = fig + kiwi + 3;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const cherry = 3 + tomato + cucumber;
+ }
+ }
+}`
+ }
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlySmallerInSize.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlySmallerInSize.ts
new file mode 100644
index 0000000000000..caa45d0d1dd49
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastesConsistentlySmallerInSize.ts
@@ -0,0 +1,92 @@
+///
+
+// @Filename: /a.ts
+//// function foo() {
+//// const p = 1;
+//// function bar() {
+//// console.log([|"Testing"|]);
+//// }
+//// console.log("yes");
+//// }
+//// class bar {
+//// constructor() {
+//// function a() {
+//// function aa() {
+//// con[|sole.log("have a good day");|]
+//// }
+////
+//// }
+//// a();
+//// function b() {
+//// function c() {
+//// export const testing = 1;
+//// const test = [|1 + testing + |]3;
+//// }
+//// }
+//// b();
+//// }
+//// c() {
+//// console.log("hello again");
+//// [|function k() {
+//// const happy = banana + avocados;
+//// }|]
+//// }
+//// }
+
+// @Filename: /b.ts
+//// export const juice = 1;
+//// export const sauce = 2;
+//// export const fig = 3;
+//// export const tomato = 4;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `juice`,`sole.log(sauce + juice);`,
+ `fig + kiwi`,
+ `function k() {
+ const cherry =tomato + kiwi;
+ }`
+ ],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {
+ "/a.ts":
+`import { sauce, juice, fig, tomato } from "./b";
+
+function foo() {
+ const p = 1;
+ function bar() {
+ console.log(juice);
+ }
+ console.log("yes");
+}
+class bar {
+ constructor() {
+ function a() {
+ function aa() {
+ console.log(sauce + juice);
+ }
+
+ }
+ a();
+ function b() {
+ function c() {
+ export const testing = 1;
+ const test = fig + kiwi3;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const cherry =tomato + kiwi;
+ }
+ }
+}`
+ }
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastesEqualInSize.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastesEqualInSize.ts
new file mode 100644
index 0000000000000..3e32e541e0d47
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastesEqualInSize.ts
@@ -0,0 +1,76 @@
+///
+
+// @Filename: /a.ts
+//// function foo() {
+//// [|console.log("yes");|]
+//// }
+//// class bar {
+//// constructor() {
+//// function a() {
+//// [|console.log("have a good day");|]
+//// }
+//// a();
+//// function b() {
+//// function c() {
+//// const test = [|1 + 2|] + 3;
+//// }
+//// }
+//// b();
+//// }
+//// c() {
+//// console.log("hello again");
+//// [|function k() {
+//// const happy = 1 + banana + avocados;
+//// }|]
+//// }
+//// }
+
+// @Filename: /b.ts
+//// export const juice = 1;
+//// export const sauce = 2;
+//// export const apple = 3;
+//// export const tomato = 4;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `console.log(juice);`,`function kl() { return sauce; }`,
+ `apple`,
+ `function k() {
+ const cherry = 3 + tomato + cucumber;
+ }`
+ ],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {
+ "/a.ts":
+`import { juice, sauce, tomato } from "./b";
+
+function foo() {
+ console.log(juice);
+}
+class bar {
+ constructor() {
+ function a() {
+ function kl() { return sauce; }
+ }
+ a();
+ function b() {
+ function c() {
+ const test = apple + 3;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const cherry = 3 + tomato + cucumber;
+ }
+ }
+}`
+ }
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastesGrowingAndShrinkingInSize.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastesGrowingAndShrinkingInSize.ts
new file mode 100644
index 0000000000000..27259b80edb82
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastesGrowingAndShrinkingInSize.ts
@@ -0,0 +1,73 @@
+///
+
+// @Filename: /a.ts
+//// function foo() {
+//// console.[|log("Hello");|]
+//// }
+//// class bar {
+//// [|constru|]ctor() {
+//// function a() {
+//// console.log("hii");
+//// }
+//// a();
+//// function b() {
+//// function c() {
+//// [|console.log("hola");|]
+//// }
+//// }
+//// b();
+//// }
+//// c() {
+//// console.log("hello again");
+//// [||]
+//// }
+//// }
+
+// @Filename: /b.ts
+//// export const juice = 1;
+//// export const sauce = 2;
+//// export const tomato = 3;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `log(sauce);`,`const apple = 1 + juice`,
+ `const kiwi = 1;`,
+ `function k() {
+ const cherry = 3 + tomato + cucumber;
+ }`
+ ],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {
+ "/a.ts":
+`import { sauce, tomato } from "./b";
+
+function foo() {
+ console.log(sauce);
+}
+class bar {
+ const apple = 1 + juicector() {
+ function a() {
+ console.log("hii");
+ }
+ a();
+ function b() {
+ function c() {
+ const kiwi = 1;
+ }
+ }
+ b();
+ }
+ c() {
+ console.log("hello again");
+ function k() {
+ const cherry = 3 + tomato + cucumber;
+ }
+ }
+}`
+ }
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastesGrowingInSize.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastesGrowingInSize.ts
new file mode 100644
index 0000000000000..9fb4fc26fdee7
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastesGrowingInSize.ts
@@ -0,0 +1,77 @@
+///
+
+// @Filename: /a.ts
+//// function foo() {
+//// [|const p = 1;|]
+//// }
+//// function too() {
+//// function k([|t: string|]) {
+//// console.log(t);
+//// }
+//// }
+//// class bar {
+//// constructor() {
+//// function a() {
+//// [| console.log("hello");|]
+//// }
+//// a();
+//// }
+//// c() {
+//// console.log("hello again");
+//// [|function k() {
+//// const happy = banana + avocados;
+//// }|]
+//// }
+//// }
+
+// @Filename: /b.ts
+//// export const juices = 1;
+//// export const sauce = 2;
+
+// @Filename: /c.ts
+//// export const figs = 3;
+//// export const tomato = 4;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts", "c.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `const t = figs;`,`apples : number`,
+ ` console.log(sauce + tomato); `,
+ `//function k(i:string) {
+ const cherry = 3 + juices + cucumber;
+// }`
+ ],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {
+ "/a.ts":
+`import { sauce, juices } from "./b";
+import { figs, tomato } from "./c";
+
+function foo() {
+ const t = figs;
+}
+function too() {
+ function k(apples : number) {
+ console.log(t);
+ }
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log(sauce + tomato);
+ }
+ a();
+ }
+ c() {
+ console.log("hello again");
+ //function k(i:string) {
+ const cherry = 3 + juices + cucumber;
+// }
+ }
+}`
+ }
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_multiplePastesShrinkingInSize.ts b/tests/cases/fourslash/server/pasteEdits_multiplePastesShrinkingInSize.ts
new file mode 100644
index 0000000000000..4a9ad20b2a8a9
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_multiplePastesShrinkingInSize.ts
@@ -0,0 +1,77 @@
+///
+
+// @Filename: /a.ts
+//// function foo() {
+//// [|console.log("Good day");|]
+//// }
+//// function too() {
+//// function k(t: string) {
+//// [|console.log("Happy Holidays");|]
+//// }
+//// }
+//// class bar {
+//// constructor() {
+//// function a() {
+//// [| console.log("hello");|]
+//// }
+//// a();
+//// }
+//// c() {
+//// console.log("hello again");
+//// function k[|() {
+//// const happy = banana + avocados;
+//// }|]
+//// }
+//// }
+
+// @Filename: /b.ts
+//// export const juices = 1;
+//// export const sauce = 2;
+
+// @Filename: /c.ts
+//// export const figs = 3;
+//// export const tomato = 4;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts", "c.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `console.log("Good ");`,`const k = figs + juices;`,
+ ` console.log(tomato);`,
+ `(kiwi: string) {
+ const cherry=tomato;
+ }`
+ ],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {
+ "/a.ts":
+`import { juices } from "./b";
+import { figs, tomato } from "./c";
+
+function foo() {
+ console.log("Good ");
+}
+function too() {
+ function k(t: string) {
+ const k = figs + juices;
+ }
+}
+class bar {
+ constructor() {
+ function a() {
+ console.log(tomato);
+ }
+ a();
+ }
+ c() {
+ console.log("hello again");
+ function k(kiwi: string) {
+ const cherry=tomato;
+ }
+ }
+}`
+ }
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_noImportNeeded.ts b/tests/cases/fourslash/server/pasteEdits_noImportNeeded.ts
index 156386a86ac7a..01f18bb50ceab 100644
--- a/tests/cases/fourslash/server/pasteEdits_noImportNeeded.ts
+++ b/tests/cases/fourslash/server/pasteEdits_noImportNeeded.ts
@@ -11,12 +11,12 @@
// @Filename: /tsconfig.json
////{ "files": ["a.ts", "b.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [`export`],
- pasteLocations: [range[0]],
- copiedFrom: { file: "a.ts", range: [range[1]] },
+ pasteLocations: [ranges[0]],
+ copiedFrom: { file: "a.ts", range: [ranges[1]] },
},
newFileContents: {}
});
diff --git a/tests/cases/fourslash/server/pasteEdits_noImportNeededInUpdatedProgram.ts b/tests/cases/fourslash/server/pasteEdits_noImportNeededInUpdatedProgram.ts
new file mode 100644
index 0000000000000..529780843d504
--- /dev/null
+++ b/tests/cases/fourslash/server/pasteEdits_noImportNeededInUpdatedProgram.ts
@@ -0,0 +1,20 @@
+///
+
+// @Filename: /a.ts
+//// [||]
+
+// @Filename: /b.ts
+//// export const b = 10;
+
+// @Filename: /tsconfig.json
+////{ "files": ["a.ts", "b.ts"] }
+
+verify.pasteEdits({
+ args: {
+ pastedText: [
+ `const b = 1;
+console.log(b);`],
+ pasteLocations: test.ranges(),
+ },
+ newFileContents: {}
+});
diff --git a/tests/cases/fourslash/server/pasteEdits_pasteComments.ts b/tests/cases/fourslash/server/pasteEdits_pasteComments.ts
index aa2d9ba943f26..eba7aca24666b 100644
--- a/tests/cases/fourslash/server/pasteEdits_pasteComments.ts
+++ b/tests/cases/fourslash/server/pasteEdits_pasteComments.ts
@@ -8,7 +8,6 @@
// @Filename: /tsconfig.json
////{ "files": ["target.ts"] }
-const range = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `/**
@@ -17,7 +16,7 @@ verify.pasteEdits({
* line 3
* line 4
*/`],
- pasteLocations: [range[0]],
+ pasteLocations: test.ranges(),
},
newFileContents: {}
});
\ No newline at end of file
diff --git a/tests/cases/fourslash/server/pasteEdits_pasteIntoSameFile.ts b/tests/cases/fourslash/server/pasteEdits_pasteIntoSameFile.ts
index 06bedadcd1724..466c0b1ddbe2c 100644
--- a/tests/cases/fourslash/server/pasteEdits_pasteIntoSameFile.ts
+++ b/tests/cases/fourslash/server/pasteEdits_pasteIntoSameFile.ts
@@ -10,12 +10,12 @@
// @Filename: /tsconfig.json
////{ "files": ["target.ts"] }
-const range = test.ranges();
+const ranges = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `console.log(k);`],
- pasteLocations: [range[1]],
- copiedFrom: { file: "target.ts", range: [range[0]] },
+ pasteLocations: [ranges[1]],
+ copiedFrom: { file: "target.ts", range: [ranges[0]] },
},
newFileContents: {}
});
diff --git a/tests/cases/fourslash/server/pasteEdits_revertUpdatedFile.ts b/tests/cases/fourslash/server/pasteEdits_revertUpdatedFile.ts
index fbe0e77ef2f99..8bb485b699540 100644
--- a/tests/cases/fourslash/server/pasteEdits_revertUpdatedFile.ts
+++ b/tests/cases/fourslash/server/pasteEdits_revertUpdatedFile.ts
@@ -17,11 +17,10 @@
// @Filename: /tsconfig.json
////{ "files": ["target.ts", "other.ts", "other2.ts"] }
-const range = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `const m = t2 + 1;`],
- pasteLocations: [range[0]],
+ pasteLocations: test.ranges(),
},
newFileContents: {
"/target.ts":
diff --git a/tests/cases/fourslash/server/pasteEdits_unknownSourceFile.ts b/tests/cases/fourslash/server/pasteEdits_unknownSourceFile.ts
index afd370f875a74..ac77ec6527c44 100644
--- a/tests/cases/fourslash/server/pasteEdits_unknownSourceFile.ts
+++ b/tests/cases/fourslash/server/pasteEdits_unknownSourceFile.ts
@@ -14,7 +14,6 @@
// @Filename: /tsconfig.json
////{ "files": ["file1.ts", "file2.ts"] }
-const range = test.ranges();
verify.pasteEdits({
args: {
pastedText: [ `interface Testing {
@@ -23,7 +22,7 @@ verify.pasteEdits({
test3: Test3;
test4: Test4;
}`],
- pasteLocations: [range[0]],
+ pasteLocations: test.ranges(),
},
newFileContents: {
"/file2.ts":