Skip to content

Update imports not working after file rename #489

@benthorner

Description

@benthorner

Running the following command:

:CocCommand workspace.renameCurrentFile

I then see / edit a prompt for the file name:

Before After (then press <CR>)
Image Image

I would expect this to update imports of this file, but no other files are changed. Example import:

import dbConfig from "@src/config/db.js";
Watchman logs
[Info  - 20:55:09] watchman watching project: /Users/ben/projects/ts-elecdb
[Info  - 20:55:09] subscribing events in /Users/ben/projects/ts-elecdb
[Info  - 20:55:32] file change of "**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}" detected: {
  "subscription": "d92d53c0-aeb7-11f0-bec8-2dc17f4578db",
  "root": "/Users/ben/projects/ts-elecdb",
  "clock": "c:1761076509:34756:1:3",
  "is_fresh_instance": false,
  "files": [
    {
      "name": "src/config/db2.ts",
      "size": 573,
      "new": true,
      "exists": true,
      "type": "f",
      "mtime_ms": 1761076532614,
      "ctime_ms": 1761076532614
    },
    {
      "name": "src/config/db.ts",
      "size": 573,
      "new": false,
      "exists": false,
      "type": "f",
      "mtime_ms": 1761076372890,
      "ctime_ms": 1761076372890
    }
  ],
  "unilateral": true,
  "since": "c:1761076509:34756:1:2",
  "version": "2025.10.20.00"
}
Verbose logs from tsserver
[Info - 19:55:08.729] Starting TS Server
[Info - 19:55:08.729] Using tsserver from: /Users/ben/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib
[Info - 19:55:08.730]  Forking...
[Info - 19:55:08.731]  Starting...
[Info - 19:55:08.731]  Forking...
[Info - 19:55:08.732]  Starting...
[Trace - 19:55:08.732]  Sending request: configure (0). Response expected: no. Current queue length: 0
Arguments: {
    "hostInfo": "coc-nvim",
    "preferences": {
        "providePrefixAndSuffixTextForRename": true,
        "allowRenameOfImportPath": true,
        "includePackageJsonAutoImports": "auto"
    },
    "watchOptions": {}
}
[Trace - 19:55:08.732]  Sending request: configure (0). Response expected: no. Current queue length: 0
Arguments: {
    "hostInfo": "coc-nvim",
    "preferences": {
        "providePrefixAndSuffixTextForRename": true,
        "allowRenameOfImportPath": true,
        "includePackageJsonAutoImports": "auto"
    },
    "watchOptions": {}
}
[Trace - 19:55:08.732]  Sending request: compilerOptionsForInferredProjects (1). Response expected: no. Current queue length: 0
Arguments: {
    "options": {
        "module": "ESNext",
        "moduleResolution": "Bundler",
        "target": "ES2020",
        "jsx": "react",
        "allowImportingTsExtensions": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "sourceMap": true,
        "allowJs": true,
        "allowSyntheticDefaultImports": true,
        "allowNonTsExtensions": true
    }
}
[Trace - 19:55:08.906]  Event received: typingsInstallerPid (0).
Data: {
    "pid": 34753
}
[Trace - 19:55:09.34]  Sending request: updateOpen (1). Response expected: yes. Current queue length: 0
Arguments: {
    "changedFiles": [],
    "closedFiles": [],
    "openFiles": [
        {
            "file": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
            "fileContent": "const _env = process.env as { [key: string]: string };\n\nconst config: { [key: string]: object } = {\n  development: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  test: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb_test\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  production: {\n    username: \"postgres\",\n    password: _env.ELECDB_DB_PASSWORD!,\n    database: \"elecdb\",\n    host: _env.ELECDB_DB_HOST!,\n    dialect: \"postgres\",\n  },\n};\n\nexport default config;\n",
            "projectRootPath": "/Users/ben/projects/ts-elecdb",
            "scriptKindName": "TS"
        }
    ]
}
[Trace - 19:55:09.34]  Sending request: updateOpen (2). Response expected: yes. Current queue length: 0
Arguments: {
    "changedFiles": [],
    "closedFiles": [],
    "openFiles": [
        {
            "file": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
            "fileContent": "const _env = process.env as { [key: string]: string };\n\nconst config: { [key: string]: object } = {\n  development: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  test: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb_test\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  production: {\n    username: \"postgres\",\n    password: _env.ELECDB_DB_PASSWORD!,\n    database: \"elecdb\",\n    host: _env.ELECDB_DB_HOST!,\n    dialect: \"postgres\",\n  },\n};\n\nexport default config;\n",
            "projectRootPath": "/Users/ben/projects/ts-elecdb",
            "scriptKindName": "TS"
        }
    ]
}
[Trace - 19:55:09.49]  Event received: projectLoadingStart (0).
Data: {
    "projectName": "/Users/ben/projects/ts-elecdb/tsconfig.json",
    "reason": "Creating possible configured project for /Users/ben/projects/ts-elecdb/src/config/db.ts to open"
}
[Trace - 19:55:09.321]  Response received: updateOpen (1). Request took 287 ms. Success: true 
Result: true
[Trace - 19:55:09.929]  Event received: projectLoadingFinish (0).
Data: {
    "projectName": "/Users/ben/projects/ts-elecdb/tsconfig.json"
}
[Trace - 19:55:09.931]  Event received: telemetry (0).
Data: {
    "telemetryEventName": "projectInfo",
    "payload": {
        "projectId": "16762a285d56e03c27b8d355b800fd4392c6b1ff0327ecb59f6f94f2bf7c1062",
        "fileStats": {
            "js": 0,
            "jsSize": 0,
            "jsx": 0,
            "jsxSize": 0,
            "ts": 8,
            "tsSize": 6323,
            "tsx": 0,
            "tsxSize": 0,
            "dts": 442,
            "dtsSize": 5809163,
            "deferred": 0,
            "deferredSize": 0
        },
        "compilerOptions": {
            "rootDir": "",
            "outDir": "",
            "paths": "",
            "module": "nodenext",
            "target": "esnext",
            "types": [],
            "sourceMap": true,
            "declaration": true,
            "declarationMap": true,
            "noUncheckedIndexedAccess": true,
            "exactOptionalPropertyTypes": true,
            "strict": true,
            "jsx": "react-jsx",
            "verbatimModuleSyntax": true,
            "isolatedModules": true,
            "noUncheckedSideEffectImports": true,
            "moduleDetection": "force",
            "skipLibCheck": true
        },
        "typeAcquisition": {
            "enable": false,
            "include": false,
            "exclude": false
        },
        "extends": false,
        "files": false,
        "include": true,
        "exclude": false,
        "compileOnSave": false,
        "configFileName": "tsconfig.json",
        "projectType": "configured",
        "languageServiceEnabled": true,
        "version": "5.9.2"
    }
}
[Trace - 19:55:09.931]  Event received: configFileDiag (0).
Data: {
    "triggerFile": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
    "configFile": "/Users/ben/projects/ts-elecdb/tsconfig.json",
    "diagnostics": []
}
[Trace - 19:55:09.932]  Response received: updateOpen (2). Request took 898 ms. Success: true 
Result: true
[Trace - 19:55:09.932]  Sending request: geterr (3). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/ben/projects/ts-elecdb/src/config/db.ts"
    ]
}
[Trace - 19:55:09.933]  Event received: syntaxDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
    "diagnostics": []
}
[Trace - 19:55:09.946]  Event received: semanticDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
    "diagnostics": []
}
[Trace - 19:55:09.947]  Event received: suggestionDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
    "diagnostics": []
}
[Trace - 19:55:09.947]  Async response received: requestCompleted (3). Request took 912 ms.
[Trace - 19:55:32.928]  Sending request: updateOpen (2). Response expected: yes. Current queue length: 0
Arguments: {
    "changedFiles": [],
    "closedFiles": [
        "/Users/ben/projects/ts-elecdb/src/config/db.ts"
    ],
    "openFiles": [
        {
            "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
            "fileContent": "const _env = process.env as { [key: string]: string };\n\nconst config: { [key: string]: object } = {\n  development: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  test: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb_test\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  production: {\n    username: \"postgres\",\n    password: _env.ELECDB_DB_PASSWORD!,\n    database: \"elecdb\",\n    host: _env.ELECDB_DB_HOST!,\n    dialect: \"postgres\",\n  },\n};\n\nexport default config;\n",
            "projectRootPath": "/Users/ben/projects/ts-elecdb",
            "scriptKindName": "TS"
        }
    ]
}
[Trace - 19:55:32.929]  Sending request: updateOpen (4). Response expected: yes. Current queue length: 0
Arguments: {
    "changedFiles": [],
    "closedFiles": [
        "/Users/ben/projects/ts-elecdb/src/config/db.ts"
    ],
    "openFiles": [
        {
            "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
            "fileContent": "const _env = process.env as { [key: string]: string };\n\nconst config: { [key: string]: object } = {\n  development: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  test: {\n    username: \"postgres\",\n    password: null,\n    database: \"elecdb_test\",\n    host: \"localhost\",\n    dialect: \"postgres\",\n  },\n  production: {\n    username: \"postgres\",\n    password: _env.ELECDB_DB_PASSWORD!,\n    database: \"elecdb\",\n    host: _env.ELECDB_DB_HOST!,\n    dialect: \"postgres\",\n  },\n};\n\nexport default config;\n",
            "projectRootPath": "/Users/ben/projects/ts-elecdb",
            "scriptKindName": "TS"
        }
    ]
}
[Trace - 19:55:32.940]  Response received: updateOpen (2). Request took 12 ms. Success: true 
Result: true
[Trace - 19:55:32.993]  Response received: updateOpen (4). Request took 64 ms. Success: true 
Result: true
[Trace - 19:55:32.993]  Sending request: geterr (5). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/ben/projects/ts-elecdb/src/config/db2.ts"
    ]
}
[Trace - 19:55:32.994]  Event received: syntaxDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
    "diagnostics": []
}
[Trace - 19:55:32.997]  Event received: semanticDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
    "diagnostics": []
}
[Trace - 19:55:32.997]  Event received: suggestionDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
    "diagnostics": []
}
[Trace - 19:55:32.997]  Async response received: requestCompleted (5). Request took 68 ms.
[Trace - 19:55:33.669]  Sending request: configure (3). Response expected: yes. Current queue length: 0
Arguments: {
    "formatOptions": {
        "tabSize": 2,
        "indentSize": 2,
        "convertTabsToSpaces": true,
        "newLineCharacter": "\n",
        "insertSpaceAfterCommaDelimiter": true,
        "insertSpaceAfterConstructor": false,
        "insertSpaceAfterSemicolonInForStatements": true,
        "insertSpaceBeforeAndAfterBinaryOperators": true,
        "insertSpaceAfterKeywordsInControlFlowStatements": true,
        "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
        "insertSpaceBeforeFunctionParenthesis": false,
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
        "insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
        "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
        "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
        "insertSpaceAfterTypeAssertion": false,
        "placeOpenBraceOnNewLineForFunctions": false,
        "placeOpenBraceOnNewLineForControlBlocks": false,
        "semicolons": "ignore"
    },
    "preferences": {
        "quotePreference": "auto",
        "importModuleSpecifierEnding": "auto",
        "jsxAttributeCompletionStyle": "auto",
        "allowTextChangesInNewFiles": true,
        "allowRenameOfImportPath": true,
        "provideRefactorNotApplicableReason": true,
        "providePrefixAndSuffixTextForRename": true,
        "includeAutomaticOptionalChainCompletions": true,
        "generateReturnInDocTemplate": true,
        "includeCompletionsForImportStatements": true,
        "includeCompletionsWithSnippetText": true,
        "includeCompletionsWithClassMemberSnippets": true,
        "includeCompletionsWithObjectLiteralMethodSnippets": true,
        "autoImportFileExcludePatterns": [],
        "preferTypeOnlyAutoImports": false,
        "useLabelDetailsInCompletionEntries": true,
        "allowIncompleteCompletions": true,
        "displayPartsForJSDoc": true,
        "includeInlayParameterNameHints": "none",
        "includeInlayParameterNameHintsWhenArgumentMatchesName": false,
        "includeInlayVariableTypeHintsWhenTypeMatchesName": false,
        "includeInlayFunctionParameterTypeHints": false,
        "includeInlayVariableTypeHints": false,
        "includeInlayPropertyDeclarationTypeHints": false,
        "includeInlayFunctionLikeReturnTypeHints": false,
        "includeInlayEnumMemberValueHints": false
    }
}
[Trace - 19:55:33.669]  Sending request: configure (6). Response expected: yes. Current queue length: 0
Arguments: {
    "formatOptions": {
        "tabSize": 2,
        "indentSize": 2,
        "convertTabsToSpaces": true,
        "newLineCharacter": "\n",
        "insertSpaceAfterCommaDelimiter": true,
        "insertSpaceAfterConstructor": false,
        "insertSpaceAfterSemicolonInForStatements": true,
        "insertSpaceBeforeAndAfterBinaryOperators": true,
        "insertSpaceAfterKeywordsInControlFlowStatements": true,
        "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
        "insertSpaceBeforeFunctionParenthesis": false,
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
        "insertSpaceAfterOpeningAndBeforeClosingEmptyBraces": false,
        "insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
        "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
        "insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": false,
        "insertSpaceAfterTypeAssertion": false,
        "placeOpenBraceOnNewLineForFunctions": false,
        "placeOpenBraceOnNewLineForControlBlocks": false,
        "semicolons": "ignore"
    },
    "preferences": {
        "quotePreference": "auto",
        "importModuleSpecifierEnding": "auto",
        "jsxAttributeCompletionStyle": "auto",
        "allowTextChangesInNewFiles": true,
        "allowRenameOfImportPath": true,
        "provideRefactorNotApplicableReason": true,
        "providePrefixAndSuffixTextForRename": true,
        "includeAutomaticOptionalChainCompletions": true,
        "generateReturnInDocTemplate": true,
        "includeCompletionsForImportStatements": true,
        "includeCompletionsWithSnippetText": true,
        "includeCompletionsWithClassMemberSnippets": true,
        "includeCompletionsWithObjectLiteralMethodSnippets": true,
        "autoImportFileExcludePatterns": [],
        "preferTypeOnlyAutoImports": false,
        "useLabelDetailsInCompletionEntries": true,
        "allowIncompleteCompletions": true,
        "displayPartsForJSDoc": true,
        "includeInlayParameterNameHints": "none",
        "includeInlayParameterNameHintsWhenArgumentMatchesName": false,
        "includeInlayVariableTypeHintsWhenTypeMatchesName": false,
        "includeInlayFunctionParameterTypeHints": false,
        "includeInlayVariableTypeHints": false,
        "includeInlayPropertyDeclarationTypeHints": false,
        "includeInlayFunctionLikeReturnTypeHints": false,
        "includeInlayEnumMemberValueHints": false
    }
}
[Trace - 19:55:33.670]  Response received: configure (3). Request took 1 ms. Success: true 
[Trace - 19:55:33.670]  Response received: configure (6). Request took 1 ms. Success: true 
[Trace - 19:55:33.670]  Sending request: getEditsForFileRename (7). Response expected: yes. Current queue length: 0
Arguments: {
    "oldFilePath": "/Users/ben/projects/ts-elecdb/src/config/db.ts",
    "newFilePath": "/Users/ben/projects/ts-elecdb/src/config/db2.ts"
}
[Trace - 19:55:33.732]  Response received: getEditsForFileRename (7). Request took 63 ms. Success: true 
Result: [
    {
        "fileName": "/Users/ben/projects/ts-elecdb/src/db/client.ts",
        "textChanges": [
            {
                "start": {
                    "line": 2,
                    "offset": 23
                },
                "end": {
                    "line": 2,
                    "offset": 40
                },
                "newText": "@src/config/db2.js"
            }
        ]
    },
    {
        "fileName": "/Users/ben/projects/ts-elecdb/src/db/admin_client.ts",
        "textChanges": [
            {
                "start": {
                    "line": 2,
                    "offset": 23
                },
                "end": {
                    "line": 2,
                    "offset": 40
                },
                "newText": "@src/config/db2.js"
            }
        ]
    }
]
[Trace - 19:55:35.476]  Event received: projectsUpdatedInBackground (0).
Data: {
    "openFiles": [
        "/Users/ben/projects/ts-elecdb/src/config/db2.ts"
    ]
}
[Trace - 19:55:35.680]  Sending request: geterr (8). Response expected: yes. Current queue length: 0
Arguments: {
    "delay": 0,
    "files": [
        "/Users/ben/projects/ts-elecdb/src/config/db2.ts"
    ]
}
[Trace - 19:55:35.682]  Event received: syntaxDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
    "diagnostics": []
}
[Trace - 19:55:35.682]  Event received: semanticDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
    "diagnostics": []
}
[Trace - 19:55:35.683]  Event received: suggestionDiag (0).
Data: {
    "file": "/Users/ben/projects/ts-elecdb/src/config/db2.ts",
    "diagnostics": []
}
[Trace - 19:55:35.683]  Async response received: requestCompleted (8). Request took 4 ms.

CocConfig (in case it's relevant)
{
  "suggest.snippetsSupport": false,  // less completion clutter
  "suggest.maxCompleteItemCount": 10,  // smaller completion
  "diagnostic.enable": false,  // disable syntax error popups
  "suggest.enableFloat": false,  // disable docs in completion
  "jedi.completion.disableSnippets": true,
  "typescript.suggest.completeFunctionCalls": false,
  "pyright.completion.snippetSupport": false
  "coc.preferences.useQuickfixForLocations": true,
  "tsserver.trace.server": "verbose"
}

Interestingly, it looks like updates are being queried (but not being applied):

{
    "fileName": "/Users/ben/projects/ts-elecdb/src/db/client.ts",
    "textChanges": [
        {
            "start": {
                "line": 2,
                "offset": 23
            },
            "end": {
                "line": 2,
                "offset": 40
            },
            "newText": "@src/config/db2.js"
        }
    ]
},

Could someone help me understand why the import update isn't working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions