Skip to content

Organize imports returning edit when imports are already sorted #39823

Open
@mjbvz

Description

@mjbvz

TypeScript Version: ^4.0.0-dev.20200729

Search Terms:

  • organize imports
  • sort
  • edits

Bug

Another case of #22912

  1. In the VS Code codebase, open a file with sorted imports such as https://github.com/microsoft/vscode/blob/2ed1fe8e22994965947bdc90556abc9a1f6b81ce/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts#L23
  2. Run organize imports

Expected behavior:
An empty edit is returned since the imports are already ordered

Actual behavior:

An edit is returned. This cause a small graphical flash and can shift your cursor around.

Here's the response:

[Trace  - 23:27:50.330] <semantic> Sending request: organizeImports (36). Response expected: yes. Current queue length: 0
Arguments: {
    "scope": {
        "type": "file",
        "args": {
            "file": "/Users/matb/projects/vscode/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts"
        }
    }
}
[Trace  - 23:27:50.344] <semantic> Response received: organizeImports (36). Request took 14 ms. Success: true 
Result: [
    {
        "fileName": "/Users/matb/projects/vscode/src/vs/workbench/contrib/webview/electron-browser/iframeWebviewElement.ts",
        "textChanges": [
            {
                "start": {
                    "line": 6,
                    "offset": 1
                },
                "end": {
                    "line": 7,
                    "offset": 1
                },
                "newText": "import { ThrottledDelayer } from 'vs/base/common/async';\nimport { Schemas } from 'vs/base/common/network';\nimport { URI } from 'vs/base/common/uri';\nimport { IEnvironmentService } from 'vs/platform/environment/common/environment';\nimport { IFileService } from 'vs/platform/files/common/files';\nimport { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';\nimport { ILogService } from 'vs/platform/log/common/log';\nimport { INotificationService } from 'vs/platform/notification/common/notification';\nimport { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';\nimport { ITunnelService } from 'vs/platform/remote/common/tunnel';\nimport { IRequestService } from 'vs/platform/request/common/request';\nimport { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';\nimport { WebviewThemeDataProvider } from 'vs/workbench/contrib/webview/browser/themeing';\nimport { WebviewContentOptions, WebviewExtensionDescription, WebviewOptions } from 'vs/workbench/contrib/webview/browser/webview';\nimport { IFrameWebview } from 'vs/workbench/contrib/webview/browser/webviewElement';\nimport { rewriteVsCodeResourceUrls, WebviewResourceRequestManager } from 'vs/workbench/contrib/webview/electron-browser/resourceLoading';\nimport { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';\n"
            },
            {
                "start": {
                    "line": 7,
                    "offset": 1
                },
                "end": {
                    "line": 8,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 8,
                    "offset": 1
                },
                "end": {
                    "line": 9,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 9,
                    "offset": 1
                },
                "end": {
                    "line": 10,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 10,
                    "offset": 1
                },
                "end": {
                    "line": 11,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 11,
                    "offset": 1
                },
                "end": {
                    "line": 12,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 12,
                    "offset": 1
                },
                "end": {
                    "line": 13,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 13,
                    "offset": 1
                },
                "end": {
                    "line": 14,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 14,
                    "offset": 1
                },
                "end": {
                    "line": 15,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 15,
                    "offset": 1
                },
                "end": {
                    "line": 16,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 16,
                    "offset": 1
                },
                "end": {
                    "line": 17,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 17,
                    "offset": 1
                },
                "end": {
                    "line": 18,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 18,
                    "offset": 1
                },
                "end": {
                    "line": 19,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 19,
                    "offset": 1
                },
                "end": {
                    "line": 20,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 20,
                    "offset": 1
                },
                "end": {
                    "line": 21,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 21,
                    "offset": 1
                },
                "end": {
                    "line": 22,
                    "offset": 1
                },
                "newText": ""
            },
            {
                "start": {
                    "line": 22,
                    "offset": 1
                },
                "end": {
                    "line": 23,
                    "offset": 1
                },
                "newText": ""
            }
        ]
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptRescheduledThis issue was previously scheduled to an earlier milestoneVS Code PriorityCritical issues that VS Code needs fixed in the current TypeScript milestone

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions