Fix LanguageClient.prepareRename() support for { defaultBehavior: true }#1748
Open
ndonfris wants to merge 1 commit into
Open
Fix LanguageClient.prepareRename() support for { defaultBehavior: true }#1748ndonfris wants to merge 1 commit into
{ defaultBehavior: true }#1748ndonfris wants to merge 1 commit into
Conversation
…ue }`
* /client behavior no longer converts `{ defaultBehavior: true }` to `null`, to now match >= 3.16.0 specification
- converts `{ defaultBehavior: true }` into the editor's default word range, allowing `textDocument/rename` requests without widening the VS Code provider type
- continues to reject `{ defaultBehavior: false }`, preventing `textDocument/rename` requests
* /client-node-tests new related `prepareRename` tests
- adds test server coverage for a controlled `{ defaultBehavior: true }` prepareRename response
- adds a dedicated integration test asserting the client converts that server result into a vscode.Range while keeping the existing Rename test focused on the standard flow
Author
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
This PR updates the language client’s prepareRename handling to support LSP { defaultBehavior: true } results by mapping them to a VS Code word range, and adds integration coverage to ensure the behavior is exercised end-to-end.
Changes:
- Convert LSP
{ defaultBehavior: true }prepareRenameresponses intodocument.getWordRangeAtPosition(...)instead ofnull. - Extend the node test server to return
{ defaultBehavior: true }for a specific position. - Add an integration test asserting the client converts
{ defaultBehavior: true }into avscode.Range.
Show a summary per file
| File | Description |
|---|---|
| client/src/common/rename.ts | Maps LSP defaultBehavior prepareRename responses to a VS Code word range. |
| client-node-tests/src/servers/testServer.ts | Makes the test server return { defaultBehavior: true } for a controlled cursor position. |
| client-node-tests/src/integration.test.ts | Adds an integration test validating the defaultBehavior-to-Range conversion. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
Comment on lines
99
to
103
| } else if (this.isDefaultBehavior(result)) { | ||
| return result.defaultBehavior === true | ||
| ? null | ||
| ? document.getWordRangeAtPosition(position) | ||
| : Promise.reject(new Error(`The element can't be renamed.`)); | ||
| } else if (result && Range.is(result.range)) { |
| const defaultBehaviorResult = await provider.prepareRename(document, defaultBehaviorPosition, tokenSource.token) as vscode.Range; | ||
|
|
||
| isInstanceOf(defaultBehaviorResult, vscode.Range); | ||
| assert.deepStrictEqual(defaultBehaviorResult, defaultBehaviorExpected); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/client behavior no longer converts
{ defaultBehavior: true }tonull, to now match >= 3.16.0 specification{ defaultBehavior: true }into the editor's default word range, allowingtextDocument/renamerequests without widening the VS Code provider type{ defaultBehavior: false }, preventingtextDocument/renamerequests/client-node-tests new related
prepareRenametests{ defaultBehavior: true }prepareRename response