@@ -918,6 +918,7 @@ async def complete_default(
918918 context : Optional [CompletionContext ],
919919 ) -> Optional [List [CompletionItem ]]:
920920 from robot .parsing .lexer .tokens import Token as RobotToken
921+ from robot .parsing .model .blocks import SettingSection
921922 from robot .parsing .model .statements import Arguments , Statement
922923
923924 if len (nodes_at_position ) > 1 and isinstance (nodes_at_position [0 ], Statement ):
@@ -943,6 +944,14 @@ async def complete_default(
943944 return await self .create_headers_completion_items (r )
944945
945946 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+
946955 return await self .create_headers_completion_items (None )
947956
948957 if len (nodes_at_position ) > 1 and isinstance (nodes_at_position [0 ], HasTokens ):
@@ -1028,6 +1037,16 @@ async def complete_SettingSection( # noqa: N802
10281037 return None
10291038
10301039 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+
10311050 statement_node = cast (Statement , nodes_at_position [0 ])
10321051 if len (statement_node .tokens ) > 0 :
10331052 token = cast (Token , statement_node .tokens [0 ])
0 commit comments