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

YAML editor generates wrong EOL characters in Windows #709

Closed
aritzbastida opened this issue Dec 9, 2021 · 8 comments
Closed

YAML editor generates wrong EOL characters in Windows #709

aritzbastida opened this issue Dec 9, 2021 · 8 comments

Comments

@aritzbastida
Copy link

When some nested property is added using the "Content Assist" tool of the YAML editor (STS 4.13.0), that is immediately reported by the validator as an error, such as "Nested mappings are not allowed in compact mappings" or "Implicit keys need to be on a single line".

As I found out, that error is caused by the EOL characters generated by the YAML editor, which follow the Linux convention (CR). However, I am running on Windows, and also installed the Windows version of STS (spring-tool-suite-4-4.13.0.RELEASE-e4.22.0-win32.win32.x86_64.self-extracting.jar).

image

@kdvolder
Copy link
Member

I thought this might be an easy fix for us, but looking a bit closer, I am not so sure. I am not sure which editor is responsible for this error. That doesn't like an STS-specific yaml editor. Anyway... I guess will try to reproduce and dig a little. But since this isn't actually an STS editor (yes the editor is shipped with STS, but it is one probably coming from Eclipse and we do not have direct control over it).

I still have some hope however that there may be some way to control the newline formats indirectly via a preference.

@kdvolder
Copy link
Member

We (@BoykoAlex and me) are not able to reproduce this so far. Here are some questions I do not have answers to:

  • what editor is being used there? There are two editors that I know of that support yaml, one is YEdit, and the other is called 'Generic Text Editor' (this comes LSP4e and it supports yaml editing).
  • what is the name / path of the file in the screenshot (This factors into what editor gets used to open a file and what editor features get enabled)
  • What kind of file is this (is this a spring properties file? Or some other yaml format).

What we tried:

  • created a spring project
  • add a 'tap,yaml' file
  • open the file with both editors (YEdit and 'generic text')
  • Both those editors seem to work fine and don't report errors entering text as in screenshot.
  • Neither of these editors looks like the screenshot (the colors are different and the editor doesn't support 'folding').

@aritzbastida Can you try clarifying some of this? Ideally you would write up a sequence of steps that begins with a clean install of STS and leads to producing the problem in question. For example:

  • install STS
  • create a new workspace
  • import this sample project in attachment using 'Import as Existing Maven project'
  • open the file /foo/bar/tap.yml
  • notice the errors which are unexpected
  • type '....' notice that it inserts the wrong kind of newline

I.e to avoid a lot of guess work on our behalf, it is best to try and be as specific as possible as to how you got into the situation shown in the screenshot. We can often fill in some blanks, but at the moment, the blanks are just too many, I have no clue at all what editor you have in that screenshot, and as a result cannot reproduce the problem.

@kdvolder
Copy link
Member

Some more things we tried (with both mentioned editors).

  • open a file that uses unix convention for newlines and type more lines
  • open a file that uses windows convention and type more lines

In both cases both editors seems to use the same newline convention as it detects in the existing file. This doesn't cause them to report problems. So this brings up another question. How did you get into a situation where the file has a mix of different newline conventions being used at the same time?

@kdvolder
Copy link
Member

Aha! Okay, so Alex was just able to reproduce something very similar to the bug report. Here are the steps:

  • create a spring boot project
  • add an application.yml boot properties file
  • editing the file using the generic text editor (which enables our spring boot specific support)
  • add some content that uses windows newlines, just by typing or pasting it in.

So far all works fine.

Now we insert a new property using the autocompletion. If we select a long / nested property, so that it results in the insertion of a multi-line completion text... then the newlines in that completion are using the unix convention. This results in exactly the error as in the bug report.

I'm still not sure this is actually the bug being reported here, but in any case it is:

  • very similar.
  • definitely a bug.
  • something we should be able to fix easily (since these newline do come from our editor completion).

@aritzbastida
Copy link
Author

Hi! I just read your comments to this issue! As I can see, you could finally reproduce the bug, but let me explain the steps nonetheless:

  1. Install STS 4.13.0
  2. Create a YAML configuration file with Windows EOL style. For example, application.yml.
  3. Open it with "Generic Editor - Spring YAML Properties". Not the same as "Generic Text Editor". Note also that the snapshot in my original post was made with Notepad++ (not a STS editor), to highlight the EOL markers. Sorry for the confusion.
    image
  4. Use content-assist (Control+Space) to enter some nested property. For example: management.info.env.enabled.
  5. The following error will be shown in the nested properties: "Nested mappings are not allowed in compact mappings"

I'm glad to know that the "bug" comes from your editor completion tool, because that means you can fix it. Hope it's not too difficult 😄

@kdvolder
Copy link
Member

Thanks for the clarifications. That clears up the last bit of confusion I had with the screenshot showing a 'unfamiliar' editor.

Hope it's not too difficult

No. Actually we pushed in a fix already yesterday. So fix should be there in the next release.

@kdvolder
Copy link
Member

FYI: If you wanted to try something sooner, nighly builds are available here:
https://dist.springsource.com/snapshot/STS4/nightly-distributions.html

@aritzbastida
Copy link
Author

Thanks for the quick fix!

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

No branches or pull requests

3 participants