@@ -918,6 +918,7 @@ async def complete_default(
918
918
context : Optional [CompletionContext ],
919
919
) -> Optional [List [CompletionItem ]]:
920
920
from robot .parsing .lexer .tokens import Token as RobotToken
921
+ from robot .parsing .model .blocks import SettingSection
921
922
from robot .parsing .model .statements import Arguments , Statement
922
923
923
924
if len (nodes_at_position ) > 1 and isinstance (nodes_at_position [0 ], Statement ):
@@ -943,6 +944,14 @@ async def complete_default(
943
944
return await self .create_headers_completion_items (r )
944
945
945
946
elif position .character == 0 :
947
+ if not nodes_at_position and position .line > 0 :
948
+ nodes_at_line_before = await get_nodes_at_position (self .model , Position (position .line - 1 , 0 ))
949
+ if nodes_at_line_before and any (isinstance (n , SettingSection ) for n in nodes_at_line_before ):
950
+ return [
951
+ * await self .create_settings_completion_items (None ),
952
+ * await self .create_headers_completion_items (None ),
953
+ ]
954
+
946
955
return await self .create_headers_completion_items (None )
947
956
948
957
if len (nodes_at_position ) > 1 and isinstance (nodes_at_position [0 ], HasTokens ):
@@ -1028,6 +1037,16 @@ async def complete_SettingSection( # noqa: N802
1028
1037
return None
1029
1038
1030
1039
if nodes_at_position .index (node ) > 0 and not isinstance (nodes_at_position [0 ], SectionHeader ):
1040
+ node_at_pos = nodes_at_position [0 ]
1041
+ if (
1042
+ position .character > 0
1043
+ and isinstance (node_at_pos , HasTokens )
1044
+ and node_at_pos .tokens
1045
+ and node_at_pos .tokens [0 ].value
1046
+ and whitespace_at_begin_of_token (node_at_pos .tokens [0 ]) > 0
1047
+ ):
1048
+ return None
1049
+
1031
1050
statement_node = cast (Statement , nodes_at_position [0 ])
1032
1051
if len (statement_node .tokens ) > 0 :
1033
1052
token = cast (Token , statement_node .tokens [0 ])
0 commit comments