You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Pasting code destroys indentation of both the pasted code and nearby lines #33760
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')
})
})
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.
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.
Reacted by James Harrington and Roberto Pereira da Costa
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).
Activity
codingthat commentedon Sep 18, 2017
I'm also seeing this on:
IIRC, before upgrading VSCode to 1.15.1, this type of operation had worked flawlessly.
alexdima commentedon Sep 20, 2017
Eric Wittle (@wittlesouth) Kevin Bloch (@codingthat) This is indeed something that shipped with 1.15. It can be turned off via
"editor.autoIndent": falsecodingthat commentedon Sep 20, 2017
Thank you so much alexandrudima , that works great. This was really annoying until you provided a workaround. :)
agos commentedon Oct 13, 2017
For what is worth, I am seeing destructive behaviour on paste even with
"editor.autoIndent"set tofalse. Also settingeditor.formatOnPastetotrueworked, though.1 remaining item
rebornix commentedon Nov 3, 2020
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.autoIndenttoadvancedto 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).Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline