sourcegraph / cody

AI that knows your entire codebase
https://cody.dev
Apache License 2.0
2.22k stars 213 forks source link

Edit: Fix incorrect indentation for undetected files #4704

Closed umpox closed 3 days ago

umpox commented 3 days ago

Description

Fixes the match-indentation function on files where there is no detected indentation.

For example, if a user tries to edit a file that just contains "hello", we should not assume the indentation for the file is 0 and then update the incoming response to match that.

[!NOTE] Some files may genuinely have 0 indentation, and this may be correct behaviour. However, it is far more reliable to just assume the LLM has gotten this right here, rather than handle different edge cases.

Test plan

  1. Create a file that just contains "hello" (no indentation)
  2. Select all of "hello" and start an edit, e.g. "write a merge sort function"
  3. Check that the edit has some indentation, and is not all set to 0 indent