Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Automatic Code Indentation #1817

@Abiddarris

Description

@Abiddarris

Issue Checklist

  • I confirm that this feature request has not been previously suggested.
  • I agree to follow the project's code of conduct.
  • I have checked and verified that I am using the latest version of AndroidIDE from GitHub or F-Droid.

Additional terms

  • I understand that feature requests are subject to evaluation and may not be implemented immediately.
  • I agree to provide additional details if needed for a clearer understanding of the requested feature.

Feature description

Summary:
There is an issue with the automatic indentation of code when moving blocks of code in the editor. The indentation is not preserved correctly, resulting in poorly formatted code.

Steps to Reproduce:

  1. Consider the following initial Java code:

    class MyClass {
        
        void myMethod() {
            int a = 10;
            int b = 5;
            if(a > b) {
                b *= a;
            } else {
                b = a--;
            }
            
            while(true) {
               int c = 100;
               if(--c < 0)
                   break;
            }
        }
        
    }
  2. Move the code block:

    int a = 10;
    int b = 5;
    if(a > b) {
        b *= a;
    } else {
        b = a--;
    }

    inside the while loop.

  3. Observe the result:

    class MyClass {
        
        void myMethod() {
            
            while(true) {
               int c = 100;
               if(--c < 0)
                    break;
                
                int a = 10;
            int b = 5;
            if(a > b) {
                b *= a;
            } else {
                b = a--;
            }
            
            }
        }
        
    }
  4. The expected correctly indented result should be:

    class MyClass {
        
        void myMethod() {
            
            while(true) {
               int c = 100;
               if(--c < 0)
                    break;
                
                int a = 10;
                int b = 5;
                if(a > b) {
                    b *= a;
                } else {
                    b = a--;
                }
            
            }
        }
        
    }
  5. Move the code inside the while loop back to outside of it.

  6. Observe the result:

    class MyClass {
        void myMethod() {
            int a = 10;
            int b = 5;
            if(a > b) {
                b *= a;
            } else {
                b = a--;
            }
            
            int c = 100;
               if(--c < 0)
                    break;
            while(true) {
                
            }
        }
    }    
  7. The expected correctly indented result should be:

    class MyClass {
        void myMethod() {
            int a = 10;
            int b = 5;
            if(a > b) {
                b *= a;
            } else {
                b = a--;
            }
            
            int c = 100;
            if(--c < 0)
                break;
            while(true) {
                
            }
        }
    }    

Actual Result:
The code is not indented correctly when moved, leading to a messy and hard-to-read code structure.

Expected Result:
The code should maintain proper indentation when moved, making it clean and readable.

Use Case

Enhanced Readability: The code remains clean and readable regardless of how blocks are moved around

Improved Maintainability: Well-indented code is easier to understand, modify, and debug.

Time-Saving: Jane saves time otherwise spent on manually fixing indentation errors, allowing her to focus more on the logic and functionality of the code.

Consistency: Ensures a consistent code style throughout the project, which is crucial for team-based development and code reviews.

Benefits

Enchanced user experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature Request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions