Line of code changes when adding a new character
已回答
I have the following line:
csv_file.write(f'{v["id"]},{v["name"]},"{v["description"]}",{v["screensCount"]},{v["lastUsed"]["value"][:10]}')
But, when I add a character (next screenshot will show it), the line format changes and I can't find a way to stop this:
csv_file.write(f'{v["id"]},{v["name"]},"{v["description"]}",{v["screensCount"]},'
f'v{v["lastUsed"]["value"][:10]}')
*When I add any character, in this case the "v" marked under the red line, the strings changes and this is quite annoying.
How can I stop this from happening?
Thank you in advance.
请先登录再写评论。
Do you mean that the line break is added?
Hi Sergey, yes. This started since the last update and I haven't been able to find a root cause.
Do you have any 3rd party plugins installed?
If so, check if disabling them and restarting PyCharm helps.
If not, it would be great if you could provide an example code that I can use for reproducing the issue to investigate it further.
Hi Sergey,
No plugins. Just the Dracula Theme and I'm using the firacode fond with ligatures https://github.com/tonsky/FiraCode. However, I've been using this one since a couple of years and this is the first time happening.
This is the PyCharm version I'm using:
Regarding the code (not the best code but does what I need), here it is:
I couldn't reproduce it.
Do you only type v letter before { and then it happens?
What is the value of Hard wrap at under File | Settings | Editor | Code Style | Python?
It seems to be the same issue as https://youtrack.jetbrains.com/issue/PY-44047/Editing-f-strings-in-lines-becoming-longer-than-hard-line-wrap-produces-unnecessary-newlines
You can find the workaround in this comment https://youtrack.jetbrains.com/issue/PY-44047/Editing-f-strings-in-lines-becoming-longer-than-hard-line-wrap-produces-unnecessary-newlines#focus=Comments-27-4347342.0-0
Hi Sergey,
The workaround, disabling the hard wrap, did the trick.
I thought it could be related to the wrapping but I couldn't find the option to disable it.
Regarding your question regarding the character, yes. But it wasn't just the v, it was any character. I would like to be able to use line wrapping anyway as it's quite helpful when working with long dictionaries but for now, this will do it.
Thank you very much for your help, I was getting quite frustrated when working with string formatting.