@@ -747,6 +747,70 @@ def completions_add(self):
747
747
files = [self .quote_fname (fn ) for fn in files ]
748
748
return files
749
749
750
+ def completions_raw_add (self , document , complete_event ):
751
+ # Get the text before the cursor
752
+ text = document .text_before_cursor
753
+
754
+ # Skip the first word and the space after it
755
+ after_command = text .split ()[- 1 ] if text .split () else ""
756
+
757
+ # Create a new Document object with the text after the command
758
+ new_document = Document (after_command , cursor_position = len (after_command ))
759
+
760
+ # Get all files not in the chat
761
+ all_files = set (self .coder .get_all_relative_files ())
762
+ all_files = all_files - set (self .coder .get_inchat_relative_files ())
763
+
764
+ # Adjusted start position to replace all of 'after_command'
765
+ adjusted_start_position = - len (after_command )
766
+
767
+ # Find matches using the pattern
768
+ matched_files = []
769
+ if after_command :
770
+ # Convert the partial path with * into a flexible pattern
771
+ pattern = after_command .lower ().replace ("*" , ".*" )
772
+ try :
773
+ pattern_re = re .compile (pattern , re .IGNORECASE )
774
+ for file_path in all_files :
775
+ if pattern_re .search (file_path ):
776
+ matched_files .append (
777
+ Completion (
778
+ text = self .quote_fname (file_path ),
779
+ start_position = adjusted_start_position ,
780
+ display = file_path ,
781
+ )
782
+ )
783
+ except re .error :
784
+ # If the pattern is not a valid regex, fall back to standard completion
785
+ pass
786
+
787
+ # If we have regular path completions, add those too
788
+ path_completions = []
789
+ if self .coder .root :
790
+ path_completer = PathCompleter (
791
+ get_paths = lambda : [self .coder .root ],
792
+ only_directories = False ,
793
+ expanduser = True ,
794
+ )
795
+
796
+ for completion in path_completer .get_completions (new_document , complete_event ):
797
+ quoted_text = self .quote_fname (after_command + completion .text )
798
+ path_completions .append (
799
+ Completion (
800
+ text = quoted_text ,
801
+ start_position = adjusted_start_position ,
802
+ display = completion .display ,
803
+ )
804
+ )
805
+
806
+ # Combine and sort all completions
807
+ all_completions = matched_files + path_completions
808
+ sorted_completions = sorted (all_completions , key = lambda c : c .display )
809
+
810
+ # Yield the sorted completions
811
+ for completion in sorted_completions :
812
+ yield completion
813
+
750
814
def glob_filtered_to_repo (self , pattern ):
751
815
if not pattern .strip ():
752
816
return []
0 commit comments