@@ -939,12 +939,12 @@ PrintCompletion(FILE *output_file,
939
939
}
940
940
}
941
941
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) {
945
944
assert (!results.empty ());
946
945
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 " );
948
948
const size_t page_size = 40 ;
949
949
bool all = false ;
950
950
@@ -956,7 +956,7 @@ DisplayCompletions(::EditLine *editline, FILE *output_file,
956
956
const size_t max_len = longest->GetCompletion ().size ();
957
957
958
958
if (results.size () < page_size) {
959
- PrintCompletion (output_file , results, max_len);
959
+ PrintCompletion (editline. m_output_file , results, max_len);
960
960
return ;
961
961
}
962
962
@@ -965,17 +965,25 @@ DisplayCompletions(::EditLine *editline, FILE *output_file,
965
965
size_t remaining = results.size () - cur_pos;
966
966
size_t next_size = all ? remaining : std::min (page_size, remaining);
967
967
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);
969
970
970
971
cur_pos += next_size;
971
972
972
973
if (cur_pos >= results.size ())
973
974
break ;
974
975
975
- fprintf (output_file , " More (Y/n/a): " );
976
+ fprintf (editline. m_output_file , " More (Y/n/a): " );
976
977
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 " );
979
987
if (got_char == -1 || reply == ' n' )
980
988
break ;
981
989
if (reply == ' a' )
@@ -1046,7 +1054,7 @@ unsigned char Editline::TabCommand(int ch) {
1046
1054
return CC_REDISPLAY;
1047
1055
}
1048
1056
1049
- DisplayCompletions (m_editline, m_output_file , results);
1057
+ DisplayCompletions (* this , results);
1050
1058
1051
1059
DisplayInput ();
1052
1060
MoveCursor (CursorLocation::BlockEnd, CursorLocation::EditingCursor);
0 commit comments