[BUG] Request textDocument/formatting failed
Describe the bug I don't know if this bug/issue is related to RobotCode or the underlying robotidy/robocop used. In my case, I use both robocop and robotidy, here is my pyproject.toml:
[tool.poetry]
name = "...."
version = "...."
description = "...."
authors = []
readme = "README.md"
package-mode = false
[tool.poetry.dependencies]
python = "^3.10"
robotframework = "^7.3.2"
robotframework-browser = "^19.6.1"
robotframework-requests = "^0.9.7"
robotframework-pabot = "^4.2.0"
robotframework-robocop = "^5.5.0"
robotframework-tidy = "^4.14.0"
robotframework-debugger = "^0.2.1"
playwright = "^1.53.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.robocop]
configure = [
"line-too-long:line_length:180",
"too-long-keyword:max_len:80",
"too-many-arguments:max_args:10",
"too-many-calls-in-keyword:max_calls:20",
"file-too-long:max_lines:800",
]
exclude = [
"no-global-variable",
]
[tool.robotidy]
spacecount = 4
indent = 4
continuation-indent = 4
line_length = 180
separator = "space"
diff = false
overwrite = true
verbose = false
configure = [
"AddMissingEnd:enabled=True",
]
Whenever there is an emoji or icon (usually added by copilot), the reformat document seems to break.
Error message:
Robotcode Request textDocument/formatting failed.Message: 'utf-8' codec can't encode character '\udd00' in position 3102: surrogates not allowed
Steps To Reproduce Steps to reproduce the behavior:
- Add � inside any .robot or .resource
- Enable format document on save in Vscode
- Save the document with the icon
- See error
If possible add some example source code like:
***Test Cases***
a simple test
Log � Something # this should show the icon the logs
Expected behavior The format document to work without any errors.
Desktop (please complete the following information):
- VS Code Version: Visual Studio Code - Insiders v1.103.0-insider
- RobotCode Version: 1.5.0
- OS: Windows
- Python Version: 3.12.4
- RobotFramework Version: 7.3.2
- Additional tools like robocop, robotidy: please look at the pyproject.toml provided
Which RoboCop version do you use?
robotidy is now deprecated and part of robocop. and also RobotCode has deprecated the use of robotidy. Did you try that already?
Does this also happens when you run robocop on the commandline? Maybe the file encoding is not correct, robot framework does only support utf8 encoded files.
any news here?
Sorry for the late reply, and thanks for keeping up with the issues. I really appreciate this extension and the time you've put in to release this for us :pray: The version used are:
robotframework-robocop = "^5.5.0"
robotframework-tidy = "^4.14.0"
You are absolutely correct about the file encoding not supporting utf16. I found a similar issue in the robotframework-lsp extension
For now, I just removed the emojis and the formatting works properly.
As for the deprecation of robotidy, I know that robotidy has been deprecated. I never upgraded robocop because I didn't have time to adapt the syntax of:
[tool.robotidy]
spacecount = 4
indent = 4
continuation-indent = 4
line_length = 180
separator = "space"
diff = false
overwrite = true
verbose = false
configure = [
"AddMissingEnd:enabled=True",
]
I took 2min tried and failed to adapt it to the new robocop syntax :sweat_smile: