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

Rename request on import path returns incorrect locs #27377

Closed
mjbvz opened this issue Sep 26, 2018 · 2 comments
Closed

Rename request on import path returns incorrect locs #27377

mjbvz opened this issue Sep 26, 2018 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Sep 26, 2018

TypeScript Version: 3.2.0-dev.20180926

Search Terms:

  • rename
  • tsserver

Code

  1. For a TS project:

a.ts

import {} from './sub/b'

sub/b.ts:

export const abc =123;
  1. Trigger a rename on the filename b in a.ts

Expected behavior:
Returned locs should only include the file name segment of the path in a.ts

Actual behavior:
Returned locs include the entire import path in a.ts

[Trace  - 2:02:28 PM] Response received: rename (180). Request took 2 ms. Success: true 
Result: {
    "info": {
        "canRename": true,
        "fileToRename": "/Users/matb/projects/san/sub/b.ts",
        "displayName": "/Users/matb/projects/san/sub/b.ts",
        "fullDisplayName": "/Users/matb/projects/san/sub/b.ts",
        "kind": "module",
        "kindModifiers": "",
        "triggerSpan": {
            "start": {
                "line": 1,
                "offset": 24
            },
            "end": {
                "line": 1,
                "offset": 25
            }
        }
    },
    "locs": [
        {
            "file": "/Users/matb/projects/san/a.ts",
            "locs": [
                {
                    "start": {
                        "line": 1,
                        "offset": 18
                    },
                    "end": {
                        "line": 1,
                        "offset": 25
                    }
                }
            ]
        }
    ]
}
@ghost
Copy link

ghost commented Sep 26, 2018

If fileToRename is set you should use that instead of locs. triggerSpan tells you the span at the original location.

@mjbvz
Copy link
Contributor Author

mjbvz commented Sep 27, 2018

Yes you are correct. I was using the api incorrectly but have fixed this on the VS code side

Sorry for the noise

@mjbvz mjbvz closed this as completed Sep 27, 2018
@mjbvz mjbvz added the Working as Intended The behavior described is the intended behavior; this is not a bug label Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

1 participant