@@ -795,7 +795,7 @@ export interface Client {
795
795
handleRemoveCodeAnalysisProblems ( refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > ;
796
796
handleFixCodeAnalysisProblems ( workspaceEdit : vscode . WorkspaceEdit , refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > ;
797
797
handleDisableAllTypeCodeAnalysisProblems ( code : string , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > ;
798
- handleCreateDeclarationOrDefinition ( copy ? : boolean ) : Promise < void > ;
798
+ handleCreateDeclarationOrDefinition ( isCopyToClipboard : boolean , codeActionRange ?: Range ) : Promise < void > ;
799
799
onInterval ( ) : void ;
800
800
dispose ( ) : void ;
801
801
addFileAssociations ( fileAssociations : string , languageId : string ) : void ;
@@ -3502,20 +3502,25 @@ export class DefaultClient implements Client {
3502
3502
return this . handleRemoveCodeAnalysisProblems ( false , identifiersAndUris ) ;
3503
3503
}
3504
3504
3505
- public async handleCreateDeclarationOrDefinition ( copy ? : boolean ) : Promise < void > {
3505
+ public async handleCreateDeclarationOrDefinition ( isCopyToClipboard : boolean , codeActionRange ?: Range ) : Promise < void > {
3506
3506
let range : vscode . Range | undefined ;
3507
3507
let uri : vscode . Uri | undefined ;
3508
3508
3509
- // range is based on the cursor position.
3510
3509
const editor : vscode . TextEditor | undefined = vscode . window . activeTextEditor ;
3511
3510
if ( editor ) {
3512
3511
uri = editor . document . uri ;
3513
- if ( editor . selection . isEmpty ) {
3514
- range = new vscode . Range ( editor . selection . active , editor . selection . active ) ;
3515
- } else if ( editor . selection . isReversed ) {
3516
- range = new vscode . Range ( editor . selection . active , editor . selection . anchor ) ;
3512
+ if ( codeActionRange !== undefined ) {
3513
+ // Request is from a code action command which provides range from code actions args.
3514
+ range = makeVscodeRange ( codeActionRange ) ;
3517
3515
} else {
3518
- range = new vscode . Range ( editor . selection . anchor , editor . selection . active ) ;
3516
+ // Request is from context menu or command palette. Use range from cursor position.
3517
+ if ( editor . selection . isEmpty ) {
3518
+ range = new vscode . Range ( editor . selection . active , editor . selection . active ) ;
3519
+ } else if ( editor . selection . isReversed ) {
3520
+ range = new vscode . Range ( editor . selection . active , editor . selection . anchor ) ;
3521
+ } else {
3522
+ range = new vscode . Range ( editor . selection . anchor , editor . selection . active ) ;
3523
+ }
3519
3524
}
3520
3525
}
3521
3526
@@ -3535,7 +3540,7 @@ export class DefaultClient implements Client {
3535
3540
line : range . end . line
3536
3541
}
3537
3542
} ,
3538
- copyToClipboard : copy ?? false
3543
+ copyToClipboard : isCopyToClipboard
3539
3544
} ;
3540
3545
3541
3546
const result : CreateDeclarationOrDefinitionResult = await this . languageClient . sendRequest ( CreateDeclarationOrDefinitionRequest , params ) ;
@@ -3825,7 +3830,7 @@ class NullClient implements Client {
3825
3830
handleRemoveCodeAnalysisProblems ( refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > { return Promise . resolve ( ) ; }
3826
3831
handleFixCodeAnalysisProblems ( workspaceEdit : vscode . WorkspaceEdit , refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > { return Promise . resolve ( ) ; }
3827
3832
handleDisableAllTypeCodeAnalysisProblems ( code : string , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > { return Promise . resolve ( ) ; }
3828
- handleCreateDeclarationOrDefinition ( copy ? : boolean ) : Promise < void > { return Promise . resolve ( ) ; }
3833
+ handleCreateDeclarationOrDefinition ( isCopyToClipboard : boolean , codeActionRange ?: Range ) : Promise < void > { return Promise . resolve ( ) ; }
3829
3834
onInterval ( ) : void { }
3830
3835
dispose ( ) : void {
3831
3836
this . booleanEvent . dispose ( ) ;
0 commit comments