Skip to content

Fix rename cursor boundary for LiquidDoc param names#1124

Merged
charlespwd merged 3 commits intomainfrom
fix-rename-boundary
Feb 6, 2026
Merged

Fix rename cursor boundary for LiquidDoc param names#1124
charlespwd merged 3 commits intomainfrom
fix-rename-boundary

Conversation

@charlespwd
Copy link
Contributor

@charlespwd charlespwd commented Feb 6, 2026

Summary

Fixes #936

Rename does not trigger when the cursor is at the first character of a @param name in a LiquidDoc block.

🤖 Generated with Claude Code

When the cursor is at the first character of a LiquidDoc @param name,
rename was not triggering because the node boundary check used the
LiquidDocParamNode position (which includes the @ prefix) instead of
the paramName position. Now we detect LiquidDocParamNode and use its
paramName sub-node for boundary calculations.

Closes #936

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use indexOf for test positions instead of hardcoded numbers, clarify
comment about @param keyword/type annotation exclusion, and expand
negative tests to cover @param keyword and space before param name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@charlespwd charlespwd marked this pull request as ready for review February 6, 2026 13:48
@charlespwd charlespwd requested a review from a team as a code owner February 6, 2026 13:49
@charlespwd
Copy link
Contributor Author

charlespwd commented Feb 6, 2026

Did 🎩 , worked great.

Comment on lines +84 to +88
if (node.type === NodeTypes.LiquidDocParamNode) {
const cursorOffset = textDocument.offsetAt(params.position);
const nameEnd = node.paramName.position.start + node.paramName.value.length;
if (cursorOffset < node.paramName.position.start || cursorOffset > nameEnd) return null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should actually change the logic for findCurrentNode instead... should probably check how hover behave. If hover is also bugged we might want to revisit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh we don't have a hover for that one.

Copy link
Contributor Author

@charlespwd charlespwd Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aight after some research the approach in the PR is better.

  • Hover is silly in the doc itself, since the doc is right after it.
  • Completion doesn't make sense, since we're defining it.

Drawbacks of changing isCovered in visitor.ts:

  • It would require changes to how TextNode calculates isCovered which would create an ambiguity for things like <tag>TextNode</tag>. Right now it's resolved by not matching on start so the > matches on the HtmlElement.

@charlespwd charlespwd marked this pull request as draft February 6, 2026 14:24
@charlespwd charlespwd marked this pull request as ready for review February 6, 2026 14:42
Copy link
Contributor

@aswamy aswamy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed an existing bug - but since yours don't cause it or make it worse, we can do a quick follow-up.

Existing bug: If you have @param {image} image and you rename image, it renames the type and the variable name. We need a patch for that.

Other than that, tophat went well ✅

…the same text

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@charlespwd
Copy link
Contributor Author

Folded that fix in :) TY for reporting!

@charlespwd charlespwd merged commit 52c1483 into main Feb 6, 2026
8 checks passed
@charlespwd charlespwd deleted the fix-rename-boundary branch February 6, 2026 17:18
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.

Can't rename LiquidDoc param when cursor is at the first character of the var name

2 participants