Skip to content

Pasting code destroys indentation of both the pasted code and nearby lines #33760

Closed

Description

  • VSCode Version: Code 1.15.1 (41abd21, 2017-08-16T17:15:57.756Z)
  • OS Version: Darwin x64 16.7.0
  • Extensions:
Extension Author (truncated) Version
vscode-docker Pet 0.0.16
jsx Twe 0.0.1
vscode-eslint dba 1.2.11
python don 0.7.0
debugger-for-chrome msj 3.2.1

Steps to Reproduce:

  1. Start with code that looks like the following:
describe('This is a test', () => {
  it('handles addTag()', (done) => {
    let tagUserUpdated = tagUser.updateField([User.USER_PREFERENCES, User.PREFERENCES_TAGS_SELECTED], 'Tag 2|Tag 1')
    .afterUpdateSuccess()
    const stateTagUpdateSuccess = setStatusMessage(
      clearUserFetching(User.setCurrentUser(stateTagUser, tagUserUpdated), tagUserUpdated), userComponentText.userUpdated
    )
    let store = createStore(testUserState, stateTagUser, applyMiddleware(thunkMiddleware))
    nock(process.env.TEST_URL).put('/users/' + userTestData[User.USER_ID]).reply(200, {})
    testAsync(store, stateTagUpdateStart, stateTagUpdateSuccess, done)
    tagUser.setSelectedTag(store.dispatch, 'Tag 1')
  })
})

  1. copy the 2nd line, and past it before the last line. The last line will be indented two spaces to match (presumably) the code that was pasted. This is a simple example, there are lots of other broken cases. Cutting and pasting code fragments is now significantly less productive than before. This seems to be a recent regression.

Reproduces without extensions: Yes/No

Activity

  1. added
    editor-core
    on Sep 3, 2017
  2. codingthat commented on Sep 18, 2017

    @codingthat

    I'm also seeing this on:

    • VSCode Version: Code 1.15.1 (41abd21, 2017-08-16T17:16:27.618Z)
    • OS Version: Linux x64 4.4.0-53-generic

    IIRC, before upgrading VSCode to 1.15.1, this type of operation had worked flawlessly.

  3. alexdima commented on Sep 20, 2017

    @alexdima
    Member

    Eric Wittle (@wittlesouth) Kevin Bloch (@codingthat) This is indeed something that shipped with 1.15. It can be turned off via "editor.autoIndent": false

  4. codingthat commented on Sep 20, 2017

    @codingthat

    Thank you so much alexandrudima , that works great. This was really annoying until you provided a workaround. :)

  5. agos commented on Oct 13, 2017

    @agos

    For what is worth, I am seeing destructive behaviour on paste even with "editor.autoIndent" set to
    false. Also setting editor.formatOnPaste to true worked, though.

  6. added
    editor-autoindent
    and removed
    editor-core
    on Oct 23, 2017
  7. added
    bug
    on Nov 16, 2017
  8. 1 remaining item

  9. added
    javascript
    on Oct 12, 2020
  10. rebornix commented on Nov 3, 2020

    @rebornix
    Contributor

    This is due to the limited architecture (regex based indentation rules and only support limited code styles), we may want to consider using formatters if they exist for indenation adjustment (if interested, we can discuss in #19847).

    For this particular issue, if the indentation rules are leading to more trouble than having no auto indent, you can set editor.autoIndent to advanced to disable the regex based indentation adjustment. As we don't have an easy good-enough fix for it, we close it for now and explore better solutions through issues like (#19847 and #34621).

  11. locked and limited conversation to collaborators on Dec 19, 2020
  12. added 3 commits that reference this issue on May 19, 2023
    dd67538
    3b8024e
    b733589
  13. added a commit that references this issue on Jun 9, 2023
    3ae10ad
  14. added a commit that references this issue on Jul 18, 2023
    835deb4
  15. 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-autoindentjavascriptwont-fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions