diff options
| author | Alexander Gonzalez <alexfertel97@gmail.com> | 2021-07-26 12:14:14 -0400 |
|---|---|---|
| committer | Alexander Gonzalez <alexfertel97@gmail.com> | 2021-07-27 18:29:22 -0400 |
| commit | 1a0a5da1a488033e4b9fdb4c4cd32854ff2859d6 (patch) | |
| tree | c6350f4fc757854a0a4e779f763458e62b0a4450 /editors/code/src/client.ts | |
| parent | 2b5798e927a24d58e38e7cd4d5c96cb68a00d82a (diff) | |
| download | rust-1a0a5da1a488033e4b9fdb4c4cd32854ff2859d6.tar.gz rust-1a0a5da1a488033e4b9fdb4c4cd32854ff2859d6.zip | |
refactor: Make handle_hover handle ranges too
Diffstat (limited to 'editors/code/src/client.ts')
| -rw-r--r-- | editors/code/src/client.ts | 44 |
1 files changed, 5 insertions, 39 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index f0c10698a0c..272cfca66d8 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -57,45 +57,11 @@ export function createClient(serverPath: string, workspace: Workspace, extraEnv: middleware: { async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { const editor = vscode.window.activeTextEditor; - const selection = editor?.selection; - return selection?.contains(position) - ? client - .sendRequest( - ra.hoverRange, - { - textDocument: - client.code2ProtocolConverter.asTextDocumentIdentifier( - document - ), - range: client.code2ProtocolConverter.asRange( - editor?.selection - ), - }, - token - ) - .then( - (result) => - client.protocol2CodeConverter.asHover(result), - (error) => { - client.handleFailedRequest( - lc.HoverRequest.type, - undefined, - error, - null - ); - return Promise.resolve(null); - } - ) - : client - .sendRequest( - lc.HoverRequest.type, - client.code2ProtocolConverter.asTextDocumentPositionParams( - document, - position - ), - token - ) - .then( + const positionOrRange = editor?.selection?.contains(position) ? client.code2ProtocolConverter.asRange(editor.selection) : client.code2ProtocolConverter.asPosition(position); + return client.sendRequest(ra.hover, { + textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document), + position: positionOrRange + }, token).then( (result) => { const hover = client.protocol2CodeConverter.asHover(result); |
