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

Error on Paste - Range Formatting #220

Closed
ghost opened this issue Aug 23, 2019 · 13 comments · Fixed by redhat-developer/yaml-language-server#179
Closed

Error on Paste - Range Formatting #220

ghost opened this issue Aug 23, 2019 · 13 comments · Fixed by redhat-developer/yaml-language-server#179
Labels

Comments

@ghost
Copy link

ghost commented Aug 23, 2019

Hello:

I have Visual Studio Code 1.38.0-insider and YAML 0.5.1.
Every time I paste code I receive a range formatting error in the Outputs window of the console.

I've tried opening a workspace, a folder, and an individual file - all with the same results.
I enabled YAML Server Trace and this is the output that I'm seeing right around the error message. It does not seem to matter if I'm pasting real YAML - or any other text - the error message is always the same:

[Trace - 9:14:58 AM] Sending request 'textDocument/rangeFormatting - (16)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/GitRepos/CFInfra/dns-zone.yaml"
    },
    "range": {
        "start": {
            "line": 151,
            "character": 0
        },
        "end": {
            "line": 151,
            "character": 17
        }
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": true
    }
}


[Trace - 9:14:58 AM] Received response 'textDocument/rangeFormatting - (16)' in 1ms. Request failed: Unhandled method textDocument/rangeFormatting (-32601).
[Error - 9:14:58 AM] Request textDocument/rangeFormatting failed.
  Message: Unhandled method textDocument/rangeFormatting
  Code: -32601 
[Trace - 9:14:58 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///d%3A/GitRepos/CFInfra/dns-zone.yaml",
    "diagnostics": [
        {
            "message": "can not read a block mapping entry; a multiline key may not be an implicit key",
            "range": {
                "start": {
                    "line": 151,
                    "character": 5102
                },
                "end": {
                    "line": 151,
                    "character": 5102
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 151,
                    "character": 5102
                },
                "end": {
                    "line": 151,
                    "character": 5102
                }
            },
            "severity": 1
        },
        {
            "message": "incomplete explicit mapping pair; a key node is missed",
            "range": {
                "start": {
                    "line": 151,
                    "character": 5104
                },
                "end": {
                    "line": 151,
                    "character": 5104
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 165,
                    "character": 5539
                },
                "end": {
                    "line": 165,
                    "character": 5539
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 179,
                    "character": 5957
                },
                "end": {
                    "line": 179,
                    "character": 5957
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 190,
                    "character": 6218
                },
                "end": {
                    "line": 190,
                    "character": 6218
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 202,
                    "character": 6577
                },
                "end": {
                    "line": 202,
                    "character": 6577
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 213,
                    "character": 6919
                },
                "end": {
                    "line": 213,
                    "character": 6919
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 224,
                    "character": 7261
                },
                "end": {
                    "line": 224,
                    "character": 7261
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 235,
                    "character": 7564
                },
                "end": {
                    "line": 235,
                    "character": 7564
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 246,
                    "character": 7874
                },
                "end": {
                    "line": 246,
                    "character": 7874
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 257,
                    "character": 8197
                },
                "end": {
                    "line": 257,
                    "character": 8197
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 268,
                    "character": 8512
                },
                "end": {
                    "line": 268,
                    "character": 8512
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 279,
                    "character": 8804
                },
                "end": {
                    "line": 279,
                    "character": 8804
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 290,
                    "character": 9103
                },
                "end": {
                    "line": 290,
                    "character": 9103
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 301,
                    "character": 9386
                },
                "end": {
                    "line": 301,
                    "character": 9386
                }
            },
            "severity": 1
        },
        {
            "message": "bad indentation of a mapping entry",
            "range": {
                "start": {
                    "line": 312,
                    "character": 9700
                },
                "end": {
                    "line": 312,
                    "character": 9700
                }
            },
            "severity": 1
        }
    ]
}
@Dylan0203
Copy link

Every time pasted code +1

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:16:34.800Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0
YAML 0.5.1.

[Trace - 5:00:59 PM] Sending request 'textDocument/rangeFormatting - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///Users/dylan/Projects/SomeProject/release_notes/20190826150200.yml"
    },
    "range": {
        "start": {
            "line": 2,
            "character": 4
        },
        "end": {
            "line": 2,
            "character": 24
        }
    },
    "options": {
        "tabSize": 2,
        "insertSpaces": true
    }
}


[Trace - 5:00:59 PM] Received response 'textDocument/rangeFormatting - (3)' in 1ms. Request failed: Unhandled method textDocument/rangeFormatting (-32601).
[Error - 5:00:59 PM] Request textDocument/rangeFormatting failed.
  Message: Unhandled method textDocument/rangeFormatting
  Code: -32601 
[Trace - 5:00:59 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/dylan/Projects/Acnit/release_notes/20190826150200.yml",
    "diagnostics": []
}

@ghost
Copy link

ghost commented Aug 27, 2019

This problem disappears if in the VSCODE YAML extension settings, formatting is turned off.
image

@JPinkney
Copy link
Contributor

I think the issue is that the format on paste VSCode setting automatically tries to call the language server protocol range formatting even if a language server doesn't explicitly say if they support it or not. (In the yaml-language-server case its undefined).

I think I can turn this off in the yaml-language-server and we should be good to go

@AliMD
Copy link

AliMD commented Aug 31, 2019

very very noisy bug! pleaaaassssss fix it with hotfix update for users, thank you.

@JPinkney
Copy link
Contributor

@AliMD What version are you on? Should already be fixed.

@fmvilas
Copy link

fmvilas commented Sep 1, 2019

@JPinkney I still see the bug, although the solution provided by @subzerochi works temporarily.

I'm running the latest version of VS Code on Mac and version 0.5.2 of this plugin.

VS Code:

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:16:34.800Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 15.6.0

Steps to reproduce:

  1. Create new empty YAML file.
  2. Type: "createOrders:" (or anything else)
  3. Open another document, type and copy the following:
bindings:
  http:
    code: 200
  1. Go to first file. Place cursor at the end of createOrders:, hit enter and then Cmd+V.
  2. Output panel opens up with the following error:
[Error - 12:38:48 PM] Request textDocument/rangeFormatting failed.
  Message: Unhandled method textDocument/rangeFormatting
  Code: -32601 

Hope it helps!

@rawkode
Copy link

rawkode commented Sep 9, 2019

@JPinkney Can we get a newer version on the VSCode market place? Currently stuck at 0.5.2

@JPinkney
Copy link
Contributor

JPinkney commented Sep 9, 2019

I've uploaded a beta release of the next version: https://github.com/redhat-developer/vscode-yaml/releases/tag/0.5.3-beta. If people try it out and it works I will go ahead with a release tomorrow.

@danielroe
Copy link

@JPinkney This still occurs for me with 0.5.3-beta.

@JPinkney
Copy link
Contributor

@danielroe Can you post all the contents of view -> output -> then selecting YAML Support from the dropdown?

The original problem was that rangeFormatting was being enabled dynamically when the formatter was turned on but now rangeFormatting is off no matter what. With that vsix on my end I can no longer reproduce

@danielroe
Copy link

@JPinkney Apologies! Looks like it's my problem. I had to quit and start again, rather than just reload, before installing the vsix in order to get the new version. Now properly installed, it's working beautifully.

@JPinkney
Copy link
Contributor

@danielroe No worries! I just wanted to make sure the fix wasn't a 'works on my machine'. I'll probably release this fix this friday

@CelsoSantos
Copy link

I was just about to uninstall it but I kinda need the Kubernetes extension now and it wouldn't let me uninstall this one.. Glad it'll be released soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants