@@ -939,12 +939,12 @@ PrintCompletion(FILE *output_file,
939939 }
940940}
941941
942- static void
943- DisplayCompletions (::EditLine *editline, FILE *output_file,
944- llvm::ArrayRef<CompletionResult::Completion> results) {
942+ void Editline::DisplayCompletions (
943+ Editline &editline, llvm::ArrayRef<CompletionResult::Completion> results) {
945944 assert (!results.empty ());
946945
947- fprintf (output_file, " \n " ANSI_CLEAR_BELOW " Available completions:\n " );
946+ fprintf (editline.m_output_file ,
947+ " \n " ANSI_CLEAR_BELOW " Available completions:\n " );
948948 const size_t page_size = 40 ;
949949 bool all = false ;
950950
@@ -956,7 +956,7 @@ DisplayCompletions(::EditLine *editline, FILE *output_file,
956956 const size_t max_len = longest->GetCompletion ().size ();
957957
958958 if (results.size () < page_size) {
959- PrintCompletion (output_file , results, max_len);
959+ PrintCompletion (editline. m_output_file , results, max_len);
960960 return ;
961961 }
962962
@@ -965,17 +965,25 @@ DisplayCompletions(::EditLine *editline, FILE *output_file,
965965 size_t remaining = results.size () - cur_pos;
966966 size_t next_size = all ? remaining : std::min (page_size, remaining);
967967
968- PrintCompletion (output_file, results.slice (cur_pos, next_size), max_len);
968+ PrintCompletion (editline.m_output_file , results.slice (cur_pos, next_size),
969+ max_len);
969970
970971 cur_pos += next_size;
971972
972973 if (cur_pos >= results.size ())
973974 break ;
974975
975- fprintf (output_file , " More (Y/n/a): " );
976+ fprintf (editline. m_output_file , " More (Y/n/a): " );
976977 char reply = ' n' ;
977- int got_char = el_getc (editline, &reply);
978- fprintf (output_file, " \n " );
978+ int got_char = el_getc (editline.m_editline , &reply);
979+ // Check for a ^C or other interruption.
980+ if (editline.m_editor_status == EditorStatus::Interrupted) {
981+ editline.m_editor_status = EditorStatus::Editing;
982+ fprintf (editline.m_output_file , " ^C\n " );
983+ break ;
984+ }
985+
986+ fprintf (editline.m_output_file , " \n " );
979987 if (got_char == -1 || reply == ' n' )
980988 break ;
981989 if (reply == ' a' )
@@ -1046,7 +1054,7 @@ unsigned char Editline::TabCommand(int ch) {
10461054 return CC_REDISPLAY;
10471055 }
10481056
1049- DisplayCompletions (m_editline, m_output_file , results);
1057+ DisplayCompletions (* this , results);
10501058
10511059 DisplayInput ();
10521060 MoveCursor (CursorLocation::BlockEnd, CursorLocation::EditingCursor);
0 commit comments