@@ -940,12 +940,12 @@ PrintCompletion(FILE *output_file,
940
940
}
941
941
}
942
942
943
- static void
944
- DisplayCompletions (::EditLine *editline, FILE *output_file,
945
- llvm::ArrayRef<CompletionResult::Completion> results) {
943
+ void Editline::DisplayCompletions (
944
+ Editline &editline, llvm::ArrayRef<CompletionResult::Completion> results) {
946
945
assert (!results.empty ());
947
946
948
- fprintf (output_file, " \n " ANSI_CLEAR_BELOW " Available completions:\n " );
947
+ fprintf (editline.m_output_file ,
948
+ " \n " ANSI_CLEAR_BELOW " Available completions:\n " );
949
949
const size_t page_size = 40 ;
950
950
bool all = false ;
951
951
@@ -957,7 +957,7 @@ DisplayCompletions(::EditLine *editline, FILE *output_file,
957
957
const size_t max_len = longest->GetCompletion ().size ();
958
958
959
959
if (results.size () < page_size) {
960
- PrintCompletion (output_file , results, max_len);
960
+ PrintCompletion (editline. m_output_file , results, max_len);
961
961
return ;
962
962
}
963
963
@@ -966,17 +966,25 @@ DisplayCompletions(::EditLine *editline, FILE *output_file,
966
966
size_t remaining = results.size () - cur_pos;
967
967
size_t next_size = all ? remaining : std::min (page_size, remaining);
968
968
969
- PrintCompletion (output_file, results.slice (cur_pos, next_size), max_len);
969
+ PrintCompletion (editline.m_output_file , results.slice (cur_pos, next_size),
970
+ max_len);
970
971
971
972
cur_pos += next_size;
972
973
973
974
if (cur_pos >= results.size ())
974
975
break ;
975
976
976
- fprintf (output_file , " More (Y/n/a): " );
977
+ fprintf (editline. m_output_file , " More (Y/n/a): " );
977
978
char reply = ' n' ;
978
- int got_char = el_getc (editline, &reply);
979
- fprintf (output_file, " \n " );
979
+ int got_char = el_getc (editline.m_editline , &reply);
980
+ // Check for a ^C or other interruption.
981
+ if (editline.m_editor_status == EditorStatus::Interrupted) {
982
+ editline.m_editor_status = EditorStatus::Editing;
983
+ fprintf (editline.m_output_file , " ^C\n " );
984
+ break ;
985
+ }
986
+
987
+ fprintf (editline.m_output_file , " \n " );
980
988
if (got_char == -1 || reply == ' n' )
981
989
break ;
982
990
if (reply == ' a' )
@@ -1047,7 +1055,7 @@ unsigned char Editline::TabCommand(int ch) {
1047
1055
return CC_REDISPLAY;
1048
1056
}
1049
1057
1050
- DisplayCompletions (m_editline, m_output_file , results);
1058
+ DisplayCompletions (* this , results);
1051
1059
1052
1060
DisplayInput ();
1053
1061
MoveCursor (CursorLocation::BlockEnd, CursorLocation::EditingCursor);
0 commit comments