@@ -631,13 +631,11 @@ def dummy_list_path(dir_name):
631631@patch ("mycli.packages.filepaths.list_path" , new = dummy_list_path )
632632@pytest .mark .parametrize (
633633 "text,expected" ,
634- # it may be that the cursor positions should be 0, but the position
635- # info is currently being dropped in find_files()
636634 [
637635 ('source ' , [('/' , 0 ), ('~' , 0 ), ('.' , 0 ), ('..' , 0 )]),
638- ("source /" , [("dir1" , - 1 ), ("file1.sql" , - 1 ), ("file2.sql" , - 1 )]),
639- ("source /dir1/" , [("subdir1" , - 6 ), ("subfile1.sql" , - 6 ), ("subfile2.sql" , - 6 )]),
640- ("source /dir1/subdir1/" , [("lastfile.sql" , - 14 )]),
636+ ("source /" , [("dir1" , 0 ), ("file1.sql" , 0 ), ("file2.sql" , 0 )]),
637+ ("source /dir1/" , [("subdir1" , 0 ), ("subfile1.sql" , 0 ), ("subfile2.sql" , 0 )]),
638+ ("source /dir1/subdir1/" , [("lastfile.sql" , 0 )]),
641639 ],
642640)
643641def test_file_name_completion (completer , complete_event , text , expected ):
@@ -697,6 +695,30 @@ def test_source_eager_completion(completer, complete_event):
697695 raise AssertionError (error )
698696
699697
698+ def test_source_leading_dot_suggestions_completion (completer , complete_event ):
699+ text = "source ./sc"
700+ position = len (text )
701+ script_filename = 'script_for_test_suite.sql'
702+ f = open (script_filename , 'w' )
703+ f .close ()
704+ special .register_special_command (..., 'source' , '\\ . filename' , 'Execute commands from file.' , aliases = ['\\ .' ])
705+ result = list (completer .get_completions (Document (text = text , cursor_position = position ), complete_event ))
706+ success = True
707+ error = 'unknown'
708+ try :
709+ assert [x .text for x in result ] == [
710+ script_filename ,
711+ 'screenshots/' ,
712+ ]
713+ except AssertionError as e :
714+ success = False
715+ error = e
716+ if os .path .exists (script_filename ):
717+ os .remove (script_filename )
718+ if not success :
719+ raise AssertionError (error )
720+
721+
700722def test_string_no_completion (completer , complete_event ):
701723 text = 'select "json'
702724 position = len (text )
0 commit comments