@@ -795,7 +795,7 @@ export interface Client {
795795 handleRemoveCodeAnalysisProblems ( refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > ;
796796 handleFixCodeAnalysisProblems ( workspaceEdit : vscode . WorkspaceEdit , refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > ;
797797 handleDisableAllTypeCodeAnalysisProblems ( code : string , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > ;
798- handleCreateDeclarationOrDefinition ( copy ? : boolean ) : Promise < void > ;
798+ handleCreateDeclarationOrDefinition ( isCopyToClipboard : boolean , codeActionRange ?: Range ) : Promise < void > ;
799799 onInterval ( ) : void ;
800800 dispose ( ) : void ;
801801 addFileAssociations ( fileAssociations : string , languageId : string ) : void ;
@@ -3502,20 +3502,25 @@ export class DefaultClient implements Client {
35023502 return this . handleRemoveCodeAnalysisProblems ( false , identifiersAndUris ) ;
35033503 }
35043504
3505- public async handleCreateDeclarationOrDefinition ( copy ? : boolean ) : Promise < void > {
3505+ public async handleCreateDeclarationOrDefinition ( isCopyToClipboard : boolean , codeActionRange ?: Range ) : Promise < void > {
35063506 let range : vscode . Range | undefined ;
35073507 let uri : vscode . Uri | undefined ;
35083508
3509- // range is based on the cursor position.
35103509 const editor : vscode . TextEditor | undefined = vscode . window . activeTextEditor ;
35113510 if ( editor ) {
35123511 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 ) ;
35173515 } 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+ }
35193524 }
35203525 }
35213526
@@ -3535,7 +3540,7 @@ export class DefaultClient implements Client {
35353540 line : range . end . line
35363541 }
35373542 } ,
3538- copyToClipboard : copy ?? false
3543+ copyToClipboard : isCopyToClipboard
35393544 } ;
35403545
35413546 const result : CreateDeclarationOrDefinitionResult = await this . languageClient . sendRequest ( CreateDeclarationOrDefinitionRequest , params ) ;
@@ -3825,7 +3830,7 @@ class NullClient implements Client {
38253830 handleRemoveCodeAnalysisProblems ( refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > { return Promise . resolve ( ) ; }
38263831 handleFixCodeAnalysisProblems ( workspaceEdit : vscode . WorkspaceEdit , refreshSquigglesOnSave : boolean , identifiersAndUris : CodeAnalysisDiagnosticIdentifiersAndUri [ ] ) : Promise < void > { return Promise . resolve ( ) ; }
38273832 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 ( ) ; }
38293834 onInterval ( ) : void { }
38303835 dispose ( ) : void {
38313836 this . booleanEvent . dispose ( ) ;
0 commit comments