Skip to content

Auto import inserts extra spaces #21891

@mjbvz

Description

@mjbvz

TypeScript Version: 2.7.1 + 2.8.0-dev-20180211

Search Terms:

Code

a.ts:

export function first(){}
export function second(){}

b.ts:

import * as a from "./a";

class Foo {
    constructor() {
        a.first
        second
    }
}

Trigger suggest at end of second in b.ts (also works for quick fix)

Bug:
Extra space inserted:

import * as arrays from "./a";

class Foo {
    constructor() {
        arrays.first
        arrays.        second
    }
}
[Trace  - 11:05:12 AM] Response received: completionEntryDetails (17). Request took 41 ms. Success: true 
Result: [
    {
        "name": "second",
        "kindModifiers": "export",
        "kind": "function",
        "displayParts": [
            {
                "text": "function",
                "kind": "keyword"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "second",
                "kind": "functionName"
            },
            {
                "text": "(",
                "kind": "punctuation"
            },
            {
                "text": ")",
                "kind": "punctuation"
            },
            {
                "text": ":",
                "kind": "punctuation"
            },
            {
                "text": " ",
                "kind": "space"
            },
            {
                "text": "void",
                "kind": "keyword"
            }
        ],
        "documentation": [],
        "tags": [],
        "codeActions": [
            {
                "description": "Change 'second' to 'arrays.second'",
                "changes": [
                    {
                        "fileName": "/Users/matb/projects/san/b.ts",
                        "textChanges": [
                            {
                                "start": {
                                    "line": 6,
                                    "offset": 1
                                },
                                "end": {
                                    "line": 6,
                                    "offset": 1
                                },
                                "newText": "        arrays."
                            }
                        ]
                    }
                ]
            }
        ],
        "source": [
            {
                "text": "./a",
                "kind": "text"
            }
        ]
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions