1
1
use crate :: session:: Session ;
2
+ use anyhow:: Result ;
3
+ use pgt_text_size:: { TextRange , TextSize } ;
2
4
use tower_lsp:: lsp_types:: { self , CodeAction , CodeActionDisabled , CodeActionOrCommand , Command } ;
3
5
4
- use pgt_workspace:: code_actions:: { CodeActionKind , CommandAction , CommandActionCategory } ;
6
+ use pgt_workspace:: code_actions:: {
7
+ CodeActionKind , CodeActionsParams , CommandAction , CommandActionCategory ,
8
+ } ;
5
9
6
10
pub fn get_actions (
7
11
session : & Session ,
@@ -12,7 +16,10 @@ pub fn get_actions(
12
16
13
17
let workspace_actions = session. workspace . pull_code_actions ( CodeActionsParams {
14
18
path,
15
- range : params. range ,
19
+ range : Some ( TextRange :: new (
20
+ TextSize :: new ( params. range . start . character ) ,
21
+ TextSize :: new ( params. range . end . character ) ,
22
+ ) ) ,
16
23
only : vec ! [ ] ,
17
24
skip : vec ! [ ] ,
18
25
} ) ?;
@@ -22,20 +29,23 @@ pub fn get_actions(
22
29
. into_iter ( )
23
30
. filter_map ( |action| match action. kind {
24
31
CodeActionKind :: Command ( command) => {
25
- let title = match command. category {
32
+ let title = match & command. category {
26
33
CommandActionCategory :: ExecuteStatement ( stmt) => {
27
- format ! ( "Execute Statement: {}..." , stmt[ ..50 ] )
34
+ format ! (
35
+ "Execute Statement: {}..." ,
36
+ stmt. chars( ) . take( 50 ) . collect:: <String >( )
37
+ )
28
38
}
29
39
} ;
30
40
31
41
return Some ( CodeAction {
32
- title,
42
+ title : title . clone ( ) ,
33
43
command : Some ( Command {
34
- title,
44
+ title : title . clone ( ) ,
35
45
command : command. category . into ( ) ,
36
46
arguments : None ,
37
47
} ) ,
38
- disabled : action
48
+ disabled : actio
39
49
. disabled_reason
40
50
. map ( |reason| CodeActionDisabled { reason } ) ,
41
51
..Default :: default ( )
0 commit comments