Skip to content

Indent behaviour with workspace/applyEdit and textDocument/completion #101773

@bmewburn

Description

@bmewburn

Issue Type: Bug

I'm seeing an inconsistency between TextEdits applied via textDocument/completion and workspace/applyEdit.

As can be seen in the screenshot the completion edit applies an extra indent whereas the workspace apply edit does not. The server trace shows the newText is the same in both situations (ignoring latter trailing indent). I tried setting editor.autoIndent to none but it did not change the observation. I would expect the extra indent on textDocument/completion to not be applied or for both edits to behave the same.

The language is PHP and the language server is intelephense.

apply_edit_v_completion

[Trace - 11:36:49 am] Received response 'textDocument/completion - (175)' in 11ms.
Result: {
    "isIncomplete": false,
    "items": [
        {
            "label": "/** [Intelephense PHPDoc] */",
            "kind": 15,
            "textEdit": {
                "range": {
                    "start": {
                        "line": 19,
                        "character": 4
                    },
                    "end": {
                        "line": 19,
                        "character": 10
                    }
                },
                "newText": "/**\n     * @param User $u \n     * @return void \n     */"
            },
            "insertTextFormat": 1,
            "additionalTextEdits": []
        }
    ]
}

[Trace - 11:52:19 am] Received request 'workspace/applyEdit - (12)'.
Params: {
    "edit": {
        "changes": {
            "file:///home/ben/Projects/laravel-test/app/User.php": [
                {
                    "range": {
                        "start": {
                            "line": 20,
                            "character": 4
                        },
                        "end": {
                            "line": 20,
                            "character": 4
                        }
                    },
                    "newText": "/**\n     * @param User $u \n     * @return void \n     */\n    "
                }
            ]
        }
    }
}

VS Code version: Code 1.46.1 (cd9ea64, 2020-06-17T21:13:08.304Z)
OS version: Linux x64 4.19.0-9-amd64

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (4 x 3100)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: disabled_software
skia_renderer: disabled_off_ok
video_decode: unavailable_off
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 7.68GB (0.31GB free)
Process Argv --no-sandbox --unity-launch
Screen Reader no
VM 0%
DESKTOP_SESSION gnome
XDG_CURRENT_DESKTOP GNOME
XDG_SESSION_DESKTOP gnome
XDG_SESSION_TYPE wayland
Extensions (8)
Extension Author (truncated) Version
vscode-intelephense-client bme 1.4.1
vscode-eslint dba 2.1.5
gitlens eam 10.2.2
vscode-apache mrm 1.2.0
vscode-docker ms- 1.3.1
csharp ms- 1.22.1
vetur oct 0.24.0
ayu tea 0.20.1

Metadata

Metadata

Assignees

Labels

*dev-questionVS Code Extension Development QuestionsnippetssuggestIntelliSense, Auto Complete

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions