@@ -1225,7 +1225,7 @@ def test_dot_completions(completions_codeeditor, qtbot):
1225
1225
@pytest .mark .order (1 )
1226
1226
@pytest .mark .parametrize (
1227
1227
"filename" , ['000_test.txt' , '.hidden' , 'any_file.txt' , 'abc.py' ,
1228
- 'part.0.parquet' ])
1228
+ 'part.0.parquet' , '/home' , '/usr/bin' ])
1229
1229
def test_file_completions (filename , mock_completions_codeeditor , qtbot ):
1230
1230
"""
1231
1231
Test that completions for files are handled as expected.
@@ -1249,21 +1249,35 @@ def test_file_completions(filename, mock_completions_codeeditor, qtbot):
1249
1249
# This checks that we can insert file completions next to a dot when a
1250
1250
# filename has several dots.
1251
1251
qtbot .keyClicks (code_editor , "'part.0.'" )
1252
+ elif filename == '/home' :
1253
+ # This checks that we can insert file completions next to a /
1254
+ qtbot .keyClicks (code_editor , "'/'" )
1255
+ elif filename == '/usr/bin' :
1256
+ # This checks that we can insert file completions next to a / placed at
1257
+ # second-level
1258
+ qtbot .keyClicks (code_editor , "'/usr/'" )
1252
1259
else :
1253
1260
qtbot .keyClicks (code_editor , f"'{ filename [0 ]} '" )
1254
1261
code_editor .moveCursor (QTextCursor .PreviousCharacter )
1255
1262
qtbot .wait (500 )
1256
1263
1257
- # Complete '0' -> '000_testing.txt'
1264
+ # Set text that will be completed
1265
+ if filename == '/home' :
1266
+ completion_text = 'home'
1267
+ elif filename == '/usr/bin' :
1268
+ completion_text = 'bin'
1269
+ else :
1270
+ completion_text = filename
1271
+
1258
1272
mock_response .side_effect = lambda lang , method , params : {'params' : [{
1259
- 'label' : f'{ filename } ' ,
1273
+ 'label' : f'{ completion_text } ' ,
1260
1274
'kind' : CompletionItemKind .FILE ,
1261
- 'sortText' : (0 , f'a{ filename } ' ),
1262
- 'insertText' : f'{ filename } ' ,
1275
+ 'sortText' : (0 , f'a{ completion_text } ' ),
1276
+ 'insertText' : f'{ completion_text } ' ,
1263
1277
'data' : {'doc_uri' : path_as_uri (__file__ )},
1264
1278
'detail' : '' ,
1265
1279
'documentation' : '' ,
1266
- 'filterText' : f'{ filename } ' ,
1280
+ 'filterText' : f'{ completion_text } ' ,
1267
1281
'insertTextFormat' : 1 ,
1268
1282
'provider' : 'LSP' ,
1269
1283
'resolve' : True
0 commit comments