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

Indented block formatting not stable #155

Closed
turadg opened this issue Mar 24, 2022 · 8 comments
Closed

Indented block formatting not stable #155

turadg opened this issue Mar 24, 2022 · 8 comments

Comments

@turadg
Copy link

turadg commented Mar 24, 2022

Bug description

A code block like this is stable,

   *   ```md
   *   Then the bounds    would iterate over the key sequence
   *   ----------------   -----------------------------------
   *   'bar', 'goomba'    bar, baz, foocount, foopriority
   *   'bar', 'joober'    bar, baz, foocount, foopriority
   * ```

But when the code block's syntax isn't specified, the tool changes to indentation syntax, which is not stable.

Actual

Example

Pass 0:

   *   ```
   *   Then the bounds    would iterate over the key sequence
   *   ----------------   -----------------------------------
   *   'bar', 'goomba'    bar, baz, foocount, foopriority
   *   'bar', 'joober'    bar, baz, foocount, foopriority
   * ```

Pass 1:

   *       Then the bounds    would iterate over the key sequence
   *       ----------------   -----------------------------------
   *       'bar', 'goomba'    bar, baz, foocount, foopriority
   *       'bar', 'joober'    bar, baz, foocount, foopriority

Pass 2:

   *         Then the bounds    would iterate over the key sequence
   *         ----------------   -----------------------------------
   *         'bar', 'goomba'    bar, baz, foocount, foopriority
   *         'bar', 'joober'    bar, baz, foocount, foopriority

Pass 3:

   *           Then the bounds    would iterate over the key sequence
   *           ----------------   -----------------------------------
   *           'bar', 'goomba'    bar, baz, foocount, foopriority
   *           'bar', 'joober'    bar, baz, foocount, foopriority

Pass 4:

   *             Then the bounds    would iterate over the key sequence
   *       ----------------   -----------------------------------
   *       'bar', 'goomba'    bar, baz, foocount, foopriority
   *       'bar', 'joober'    bar, baz, foocount, foopriority

Pass 5:

   *               Then the bounds    would iterate over the key sequence
   *         ----------------   -----------------------------------
   *         'bar', 'goomba'    bar, baz, foocount, foopriority
   *         'bar', 'joober'    bar, baz, foocount, foopriority

Pass 6:

   *                 Then the bounds    would iterate over the key sequence
   *           ----------------   -----------------------------------
   *           'bar', 'goomba'    bar, baz, foocount, foopriority
   *           'bar', 'joober'    bar, baz, foocount, foopriority

Pass 7:

   *                   Then the bounds    would iterate over the key sequence
   *       ----------------   -----------------------------------
   *       'bar', 'goomba'    bar, baz, foocount, foopriority
   *       'bar', 'joober'    bar, baz, foocount, foopriority

Expected

  • Indented blocks aren't reformatted
@hosseinmd
Copy link
Owner

Use intention instead of backtick, when you're wrapping with backtick, plugin assume this is code and formatting them as code. Add four space as intention like this

   *     Then the bounds    would iterate over the key sequence
   *     ----------------   -----------------------------------
   *     'bar', 'goomba'    bar, baz, foocount, foopriority
   *     'bar', 'joober'    bar, baz, foocount, foopriority

@hosseinmd hosseinmd reopened this Mar 25, 2022
@turadg
Copy link
Author

turadg commented Mar 29, 2022

I think what you're advising is exactly what's in Pass 1. Notice that on the next format it moves and on each format it moves again. ie not stable

@hosseinmd
Copy link
Owner

Please give me your comment completely.

@turadg
Copy link
Author

turadg commented Mar 30, 2022

Here's a failing case in 0.3.34:

 /**
   * @returns {boolean} result
   *
   *         Then the bounds    would iterate over the key sequence
   *         ----------------   -----------------------------------
   *         'bar', 'goomba'    bar, baz, foocount, foopriority
   *         'bar', 'joober'    bar, baz, foocount, foopriority
   */

@turadg
Copy link
Author

turadg commented Aug 29, 2022

@hosseinmd have you confirmed this is a bug? Is it one you intend to work on or will it require a community fix?

@hosseinmd
Copy link
Owner

Yes, this is a bug. I will, but Now I don't have enough time.

@turadg
Copy link
Author

turadg commented Jul 10, 2023

May be fixed by prettier/prettier#13532

If so will require #194

@turadg turadg closed this as completed Jul 21, 2023
@turadg
Copy link
Author

turadg commented Jul 21, 2023

It's not fully stable but I think the remaining problem is #178

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

No branches or pull requests

2 participants