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

Feature: respect indent in brace-based languages #566

Open
mikehearn opened this issue Apr 20, 2024 · 0 comments
Open

Feature: respect indent in brace-based languages #566

mikehearn opened this issue Apr 20, 2024 · 0 comments
Labels
question Further information is requested

Comments

@mikehearn
Copy link

Claude 3 Opus likes to append methods to a Java/Kotlin class by doing a search/replace on an empty block whilst providing indented text. Aider just adds this to the end of the file, but it would be smarter to spot when the file ends with a brace and position the newly inserted block within the right scope, as determined by computing the minimum indent of the provided block.

Example:

 <<<<<<< SEARCH
 =======
     private fun invokeTask(task: BuildTask, cacheKey: String?, retryCount: Int = 0): Any? {
         check(retryCount <= maxRetries)
         return try {
             executeTask(task, listOf(task), 0, cacheKey)
         } catch (e: RetryLater) {
             if (retryCount < maxRetries) {
                 Logger.info("Task ${task.taskDisplayName} requested retry (attempt ${retryCount + 1}): ${e.message}")
                 if (e.delay != null) {
                     Logger.info("Waiting ${e.delay} before retrying ${task.taskDisplayName}")
                     Thread.sleep(e.delay.toMillis())
                 }
                 invokeTask(task, cacheKey, retryCount + 1)
             } else {
                 Logger.warn("Task ${task.taskDisplayName} failed after $maxRetries retries")
                 throw e
             }
         }
     }

 >>>>>>> REPLACE

Here, the right place to add the new method is inside the class, so one line above where aider chooses to put it.

@paul-gauthier paul-gauthier added the question Further information is requested label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants