Skip to content

The indentation is incorrectly changed after pasting #147223

Closed

Description

@Z-E-D

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.66.0
  • OS Version: Windows 7

Steps to Reproduce:

The indentation of the existing closing code is changed after pasting, depending on the level of indentation of the copied code. Here is the animated screenshot:
Indentation after paste

  1. the first copied block (top) has indentation with one tab more than the resulting indentation -> after pasting, the existing closing bracket has one tab less indentation;
  2. the second copied block (bottom) has indentation with three tabs less then the resulting indentation -> after pasting, the existing closing bracket has three tabs more indentation.

I have "editor.autoIndent": "full" because I like that option of VSCode very much with its automatic indentation based on the surrounding code.

Maybe these issues are related: #86301 and #85781.

Activity

  1. added
    bug
    editor-autoindent
    on Apr 11, 2022
  2. rebornix commented on Dec 13, 2022

    @rebornix
    Contributor

    It looks like that the indentation rules for JS is not covering this case. Currently the indentation rules for
    auto indent feature in VS Code is regex based, which doesn't really understand the scope (function, statement) etc. Formatting works more consistently in this scenario, so I would recommend to enable formatting on type or save. Closing this as we don't expect to get around it in the near future.

  3. Z-E-D commented on Dec 13, 2022

    @Z-E-D
    Author

    This is not problem only with JS files. Here is HTML:
    2022-12-13_07-51-05

    Here is CSS:
    2022-12-13_07-53-51

    And JSON:
    2022-12-13_08-05-04

    I don't understand how your regex code could add the proper number of tabs/space characters just fine to all pasted lines, except the last one.

    Could you please point me in the right direction, where should I look in your code? I am not that good with TypeScript, but I am quite fine with regular expressions and maybe I could fix that for you.

  4. locked and limited conversation to collaborators on Jan 29, 2023
  5. added 3 commits that reference this issue on May 19, 2023
    dd67538
    3b8024e
    b733589
  6. added a commit that references this issue on Jun 9, 2023
    3ae10ad
  7. added a commit that references this issue on Jul 18, 2023
    835deb4
  8. added 5 commits that reference this issue on Sep 30, 2023
    38fa637
    886e568
    6ed6108
    1e2c3d3
    8b96807
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugeditor-autoindentwont-fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions