@@ -17,15 +17,13 @@ pub(crate) fn get_range_to_replace(ctx: &TreesitterContext) -> TextRange {
1717 let sanitized = remove_sanitized_token ( content) ;
1818 let length = sanitized. len ( ) ;
1919
20- let start = node. start_byte ( ) ;
21- let end = start + length;
20+ let mut start = node. start_byte ( ) ;
21+ let mut end = start + length;
2222
23- // let compl_text_in_quotes =
24- // completion_text.starts_with('"') && completion_text.ends_with('"');
25-
26- // if compl_text_in_quotes && sanitized == r#""""# {
27- // return TextRange::new(start.try_into().unwrap(), end.try_into().unwrap());
28- // }
23+ if node_text_surrounded_by_quotes ( ctx) {
24+ start -= 1 ;
25+ end -= 1 ;
26+ }
2927
3028 TextRange :: new ( start. try_into ( ) . unwrap ( ) , end. try_into ( ) . unwrap ( ) )
3129 }
@@ -39,33 +37,24 @@ pub(crate) fn with_schema_or_alias(
3937 schema_or_alias_name : Option < & str > ,
4038) -> String {
4139 let is_already_prefixed_with_schema_name = ctx. schema_or_alias_name . is_some ( ) ;
40+
4241 let with_quotes = node_text_surrounded_by_quotes ( ctx) ;
4342
43+ let node_under_cursor_txt = ctx. get_node_under_cursor_content ( ) . unwrap_or ( "" . into ( ) ) ;
44+ let node_under_cursor_txt = node_under_cursor_txt. as_str ( ) ;
45+ let is_quote_sanitized = is_sanitized_token_with_quote ( node_under_cursor_txt) ;
46+
4447 if schema_or_alias_name. is_none_or ( |s| s == "public" ) || is_already_prefixed_with_schema_name {
45- if with_quotes {
46- format ! ( r#""{}""# , item_name) . to_string ( )
47- } else {
48- item_name. to_string ( )
49- }
48+ item_name. to_string ( )
5049 } else {
5150 let schema_or_als = schema_or_alias_name. unwrap ( ) ;
5251
53- if with_quotes {
54- format ! ( r#""{}"."{}""# , schema_or_als. replace( '"' , "" ) , item_name) . to_string ( )
52+ if is_quote_sanitized {
53+ format ! ( r#"{}"."{}""# , schema_or_als. replace( '"' , "" ) , item_name) . to_string ( )
54+ } else if with_quotes {
55+ format ! ( r#"{}"."{}"# , schema_or_als. replace( '"' , "" ) , item_name) . to_string ( )
5556 } else {
5657 format ! ( "{}.{}" , schema_or_als, item_name) . to_string ( )
5758 }
5859 }
5960}
60-
61- pub ( crate ) fn with_closed_quote ( ctx : & TreesitterContext , item_name : & str ) -> String {
62- let mut with_closed = String :: from ( item_name) ;
63-
64- if let Some ( content) = ctx. get_node_under_cursor_content ( ) {
65- if is_sanitized_token_with_quote ( content. as_str ( ) ) {
66- with_closed. push ( '"' ) ;
67- }
68- }
69-
70- with_closed
71- }
0 commit comments