Editing python code frequently output/insert misindented code

Example:

I asked Cody (using the edit command at the cursor to simply implement the function above. The cody output is the bottom part.

Using pycharm and the cody 7

2 Likes

Hey @olejorgenb
Is the wrong indentation behavior a permanent problem, or does it only happen once in a while?

It doesn’t happen all the time, but frequently enough to be quite annoying.

Not sure about the “trigger”.

Another example:

    for (edge, deps) in c.deps.items():
        # Loop over all dependencies of the current node
        for dep in deps:
            # Get the dependency node
            <Cursor was here>
                        # Split deps into two series: one for max values and one for min values
                        max_series = deps.groupby(level=0).max()
                        min_series = deps.groupby(level=0).min()
            
                        # Plot the band using the max and min series
                        plot_band(depfig, min_series, max_series, f"{edge}-{dep}")
            
            plot_band(depfig, )

EDIT: if I select

       # Get the dependency node
       plot_band(depfig, )

Before issuing the edit command it works correctly

I’m seeing the same behavior. I see it happen more towards the late hours of my working/coding sessions, which probably is just by chance.

Does this means it happens if a chat session goes too long?

I just got a chat reply with the wrong indentation as well; the indentation was one level too low. The chat session wasn’t very long.

1 Like

Hey all,

there is now a new patch release 1.34.3 available for Cody in vs code.
Let me hear if this fixes the issue.

Still broken in PyCharm/Jetbrains:

    def send_reqeust(self, method, params):
        """Send request synchronously"""
       <CURSOR when issuing edit request> 
        def send_reqeust(self, method, params):
                """Send request synchronously"""
                response_event = threading.Event()
                response_data = {}
        
                def handler(response):
                    response_data["result"] = response
                    response_event.set()
        
                self.send_request_async(method, params, handler)
                response_event.wait()
                return response_data.get("result")

(might be a slightly different issue though. My prompt said something along these lines: “Implement this function …”)

It’s usually because the AI generates code without indentation and then it has problems incorporating it into the surrounding indentation, right?

(Selection the whole function seems to work better in general, but IIRC still not always.)

Hey @olejorgenb the team is working on it to improve the indentation for better UX.

Thank you for reporting.

It seems like moving the cursor to the start of the line usually make it able to insert at the correct indentation.

Thank’s for the feedback.

This helps alot to pin down the issue.