script-lab icon indicating copy to clipboard operation
script-lab copied to clipboard

Copy to clipboard should honor tab size settings for entire yaml file

Open AlexJerabek opened this issue 6 years ago • 7 comments

Bug Report

  • Environment: Beta

Expected behavior:

Copying the snippet to the clipboard should have a consistent tab size for the entire file. This includes the tabs before "content" lines.

Actual behavior:

The SL-default of 2 spaces is applied to the yaml, except for user-generated content.

Steps to Reproduce:

  1. Set "editor.tabSize" to 4
  2. Run formatting tool.
  3. Export a snippet by copying it to the clipboard.
  4. Paste it in VS Code.

Screenshot:

spaces

AlexJerabek avatar Feb 27 '19 19:02 AlexJerabek

Don't know if I fully understand the request -- but in any case, since it's not critical, putting it into the 1.3 milestone to review later.

Zlatkovsky avatar Feb 28 '19 23:02 Zlatkovsky

Also, @AlexJerabek , if you'd like to submit your own fix, by all means feel free :-)

Zlatkovsky avatar Feb 28 '19 23:02 Zlatkovsky

The culprit here is that the YAML.dumpSafe is not being passed the tabSize. (assuming they have a parameter you can pass for tabSize similar to JSON.stringify)

nico-bellante avatar Mar 01 '19 07:03 nico-bellante

That's the part I'm not sure about, is whether it even makes sense for the rest of the YAML to honor those tab sizes. Alex, let's talk in person at some point and see if you can convince me :-)

Zlatkovsky avatar Mar 01 '19 18:03 Zlatkovsky

I think the argument for it should is much stronger than it shouldn't. The main reason I see is it looks strange to see 2 space tabs and 4 space tabs together.

nico-bellante avatar Mar 01 '19 18:03 nico-bellante

Aside from looking strange, it messes with VS Code's tab size autodetect.

I understand this is low priority (unless customers are using the yaml in similar manners as the content team). Just reporting an issue as it's encountered.

AlexJerabek avatar Mar 01 '19 19:03 AlexJerabek

Well, YAML spec allows for either 2 spaces or 4 spaces, so we're OK on that front. But what if someone chooses 3 spaces?...

That said, fine. We can have the logic use "editor.tabSize" if it's 2 or 4, and default to 4 otherwise. The safeDump method accepts an "indent" option (see more at https://www.npmjs.com/package/js-yaml). So it should be fairly trivial to fix

Zlatkovsky avatar Mar 01 '19 19:03 Zlatkovsky