Skip to content

fix(gdscript): clamp symbol ranges so replace_symbol_body keeps separators (#1952) - #2052

Open
Yu-0312 wants to merge 1 commit into
oraios:mainfrom
Yu-0312:pr-1952-gdscript-body-range
Open

Yu-0312 wants to merge 1 commit into
oraios:mainfrom
Yu-0312:pr-1952-gdscript-body-range

Conversation

@Yu-0312

@Yu-0312 Yu-0312 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1952.

replace_symbol_body deleted the blank separator immediately before the next GDScript function because Godot reports a symbol range ending at the start of the next top-level construct (or on the blank line).

Change

In GodotLanguageServer._fix_symbol_ranges, after the existing off-by-one end-column fix, _clamp_trailing_blank_lines walks the range end back to the last non-blank line of the symbol. selectionRange (the identifier) is not clamped. Document-symbol cache version bumped to 2.

Tests

test_godot_range_clamp.py: clamp unit cases + end-to-end _fix_symbol_ranges on a two-function fixture; selectionRange preserved.

Checklist

  • CHANGELOG.md updated
  • Single logical change

Further ideas for maintainers (not in this PR)

  1. A Godot editor e2e (replace_symbol_body on two adjacent functions) would pin this against a live LS; only pure-function tests here.
  2. If Godot ever reports correct ends, the clamp becomes a no-op (safe to keep or gate on Godot version like _fix_range_end).

@Yu-0312
Yu-0312 force-pushed the pr-1952-gdscript-body-range branch from 114be39 to dc88cf2 Compare September 20, 2026 09:48
@Yu-0312
Yu-0312 force-pushed the pr-1952-gdscript-body-range branch from dc88cf2 to 61a5e7d Compare September 20, 2026 16:46
@Yu-0312

Yu-0312 commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main, squashed to a single commit (author: Yu-0312 / wang.yuchi.312@gmail.com), ruff format/ruff check clean, and unit tests for this change pass locally.

Remaining CI red on some jobs (ccls / R / nextflow / clojure / perl) also fails on unrelated PRs and looks like runner/LS flake — happy to re-run if needed.

Ready for review when you have bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replace_symbol_body removes separator whitespace before the following GDScript function

1 participant