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

Drunk behavior of moveLinesDownAction #54829

Closed
Oreilles opened this issue Jul 22, 2018 · 3 comments
Closed

Drunk behavior of moveLinesDownAction #54829

Oreilles opened this issue Jul 22, 2018 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@Oreilles
Copy link

  • VSCode Version: 1.25.1 (1.25.1)
  • OS Version: OSX 10.11.6

Steps to Reproduce:

  1. Select brackets block
  2. alt+down

vscodebug

@vscodebot vscodebot bot added the editor label Jul 22, 2018
@alexdima alexdima added the editor-autoindent Editor auto indentation issues label Jul 23, 2018
@rebornix rebornix added the bug Issue identified by VS Code Team member as probable bug label Sep 4, 2018
@rebornix
Copy link
Member

Good catch and it helps me understand what's going on there.

Let me use a simple if block to describe the root cause here, will work on it after the issue grooming.

console.log();

if (true) {
  console.log();
}

We have 5 lines of code here. Say if we are going to move the 3rd line down, internally we cut the 4th line and paste after 2nd line. So console.log(); will be the new 3rd line, and if (true) { will be the new 4th. To adjust the indentation of if (true) { we need to check the onEnter rules on the new 3rd line console.log(); however right now, we are still checking if (true) {, which will tell us to increase the indentation.

The expected result should be

console.log();

console.log();
if (true) {
}

However due to the wrong onEnter rules checking, we get

console.log();

console.log();
  if (true) {
}

@thany
Copy link

thany commented Nov 5, 2018

VSCode simply shouldn't touch the indenting when moving lines up and down. It's not moving a statement, it's moving the whole line. So the editor should just stop trying to be smarter than it can be.

The correct indentation is very hard to predict with 100% accuracy, and even 99% isn't good enough, because the remaining 1% will drive one insane. Unfinished code is likely not (yet) well-formed, making it impossible to correctly predict the indentation the developer intents to go for.

@adamreisnz
Copy link

Fully agree with @thany's statement. There are a lot of auto indentation issues when moving code up and down (see other referenced issues). It might be best to (allow us to) disable auto indentation when moving code up and down, because it's clearly not working as expected in a lot of cases, and it doesn't seem like these issues are high on the priority list.

@rebornix rebornix added this to the November 2020 milestone Nov 3, 2020
@sandy081 sandy081 added the verified Verification succeeded label Dec 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants
@thany @adamreisnz @rebornix @alexdima @sandy081 @Oreilles and others