ISSUE DESCRIPTION Extract function extracts too much When triggering Extract function…
- User
ISSUE DESCRIPTION
Extract function extracts too much When triggering
Extract functionwith the selection:rs/// prepare an empty gleam project in the `target_path` /// fn prepare_project_structure( target_path target: TargetPath, user_id user_id: uuid.Uuid, ) -> Result(Nil, SubmitError) { // get the priv dir use priv <- result.try( application.priv_directory("gleeps") |> result.replace_error(FailedToFindPrivDirectory), ) // copy the base project to the target_path use _ <- result.try( simplifile.copy_directory(filepath.join(priv, "base_project"), target.path) |> result.replace_error(FailedToCopyBaseProject), ) // replace $PROJECT_NAME placeholder in the gleam.toml // <-------------------------------------------------------------- selected from here let toml_path = target.path |> filepath.join("gleam.toml") use gleam_toml <- result.try( toml_path |> simplifile.read |> result.replace_error(FailedToReadGleamToml), ) let gleam_toml = gleam_toml |> string.replace("$PROJECT_NAME", with: user_id_to_string(user_id)) simplifile.write(toml_path, gleam_toml) |> result.replace_error(FailedToWriteGleamToml) // <---------------------------------------------------------------- to here }It will extract the entire function content into a new function leaving:
rsfn prepare_project_structure( target_path target: TargetPath, user_id user_id: uuid.Uuid, ) -> Result(Nil, SubmitError) { function(target, user_id) }instead of the expected:
rs - Assistant
I’ll trace the extract-function implementation and its selection/range handling, reproduce the reported boundary behavior with existing tests or a focused temporary check, then patch the smallest relevant logic. I’ll avoid modifying tests, run the affected test suite, inspect the final diff, and only then submit.
- Assistant
The extraction visitor accumulates every statement for which
overlapsis true. That helper treats touching range endpoints as overlap, which is problematic for LSP’s half-open selections: starting exactly where the preceding statement ends can incorrectly include that preceding statement. I’ll apply strict half-open overlap only to ExtractFunction, preserving the inclusive behavior used by unrelated cursor-based code actions. - Assistant
The targeted patch is in place. The repository’s Rust toolchain is not configured (
rustuphas no default toolchain), so Cargo tests and formatting cannot run in this environment. I’ll still verify the exact diff, ensure the helper is positioned correctly and formatting is conventional, and check for any available local toolchain before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.