Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on getPasteEdits between on disk file and unsaved file #60087

Closed
mjbvz opened this issue Sep 27, 2024 · 0 comments Β· Fixed by #60362
Closed

Exception on getPasteEdits between on disk file and unsaved file #60087

mjbvz opened this issue Sep 27, 2024 · 0 comments Β· Fixed by #60362
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Sep 27, 2024

πŸ”Ž Search Terms

  • getPasteEdits

  • update imports on paste

πŸ•— Version & Regression Information

5.7.0-dev.20240926, not a regression

⏯ Playground Link

No response

πŸ’» Code

  1. In VS Code, set "typescript.experimental.updateImportsOnPaste": true
  2. create a file index.ts with the following contents and save it to disk:
export const a = 1;
console.log(a);
  1. Copy console.log(a);

  2. Create a new untitled file. Change the language mode to typescript

  3. Paste

πŸ™ Actual behavior

Err 1215  [12:10:42.591] Exception on executing command {
  "seq": 266,
  "type": "request",
  "command": "getPasteEdits",
  "arguments": {
    "file": "^/untitled/ts-nul-authority/Untitled-1",
    "pastedText": [
      "const a = 1;"
    ],
    "pasteLocations": [
      {
        "start": {
          "line": 1,
          "offset": 1
        },
        "end": {
          "line": 1,
          "offset": 1
        }
      }
    ],
    "copiedFrom": {
      "file": "/Users/matb/projects/sandbox/index.ts",
      "spans": [
        {
          "start": {
            "line": 1,
            "offset": 1
          },
          "end": {
            "line": 1,
            "offset": 13
          }
        }
      ]
    }
  }
}:

    Project '/dev/null/inferredProject3*' does not contain document '/Users/matb/projects/sandbox/index.ts'

    Error: Project '/dev/null/inferredProject3*' does not contain document '/Users/matb/projects/sandbox/index.ts'
        at Object.ThrowProjectDoesNotContainDocument (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:183462:11)
        at InferredProject2.getScriptInfoForNormalizedPath (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:185614:21)
        at /Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:193707:291
        at Array.map (<anonymous>)
        at IpcIOSession.getPasteEdits (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:193707:101)
        at getPasteEdits (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:191842:43)
        at /Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:194087:15
        at IpcIOSession.executeWithRequestId (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:194076:14)
        at IpcIOSession.executeCommand (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:194085:29)
        at IpcIOSession.onMessage (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/typescript.js:194133:68)
        at process.<anonymous> (/Users/matb/.vscode-insiders/extensions/ms-vscode.vscode-typescript-next-5.7.20240926/node_modules/typescript/lib/tsserver.js:525:14)
        at process.emit (node:events:519:28)
        at emit (node:internal/child_process:951:14)
        at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

πŸ™‚ Expected behavior

No error. I think no edits should be generated in this case because we can't import anything

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Oct 1, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.7.0 milestone Oct 1, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants