diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 53fa64103abf..7e6a2f55e373 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -630,7 +630,21 @@ Editline::GetCharFromInputFileCallback (EditLine *e, char *c) if (editline && editline->m_got_eof == false) { char ch = ::fgetc(editline->GetInputFile()); - if (ch == '\x04' || ch == EOF) + if (ch == '\x04') + { + // Only turn a CTRL+D into a EOF if we receive the + // CTRL+D an empty line, otherwise it will forward + // delete the character at the cursor + const LineInfo *line_info = ::el_line(e); + if (line_info != NULL && + line_info->buffer == line_info->cursor && + line_info->cursor == line_info->lastchar) + { + ch = EOF; + } + } + + if (ch == EOF) { editline->m_got_eof = true; }