Skip to content

Tidy Code does not indent nested blocks properly if braces are missing #1815

@Hari3

Description

@Hari3

Nature of issue? Bug

  • Found a bug

Details about the bug:

  • Web browser and version: Chrome 89.0.4389.82
  • Operating System: Windows 10
  • Steps to reproduce this bug:
  1. Create a nested block(branch or loop), inside another branch or loop without using braces anywhere
    a)Check this Sample editor file
    Here are the contents for ease of access
// Indent Issue
// Create a copy and Tidy Code (Edit -> Tidy Code)
// This is already indented properly
do
  if(true)
    console.log("foo")
  else
    console.log("bar")
while(false)
  
// Same is true for while and for loops:

for(i=0;i<10;i++)
  if(true)
    console.log("foo")
  else
    console.log("bar")

while(i<12)
  if(true)
    i++
  else
    i--
  
console.log("foo")

// Note that out put is same in before and after tiding code, "foo" is printed 12 times
  1. Click on Edit > Tidy Code
    a. Expected, this code is already indented properly: if and else lines up. No change should occur
    b. Actual: else gets aligned with previous block(while, do or for)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions