diff --git a/lib/UserInterface/textinput/Editor.cpp b/lib/UserInterface/textinput/Editor.cpp index 027e7c76..8eb61378 100644 --- a/lib/UserInterface/textinput/Editor.cpp +++ b/lib/UserInterface/textinput/Editor.cpp @@ -20,6 +20,7 @@ #include "textinput/Callbacks.h" #include "textinput/History.h" #include "textinput/KeyBinding.h" +#include "textinput/StreamReaderUnix.h" #include "textinput/TextInput.h" #include "textinput/TextInputContext.h" @@ -449,6 +450,9 @@ namespace textinput { ProcessMove(kMoveEnd, R); std::vector completions; TabCompletion* tc = fContext->GetCompletion(); + Reader* reader = fContext->GetReaders()[0]; + StreamReaderUnix* streamReader = (StreamReaderUnix*)(reader); + if (!streamReader->IsFromTTY()) return kPRSuccess; if (tc) { bool ret = tc->Complete(Line, Cursor, R, completions); if (ret) { diff --git a/lib/UserInterface/textinput/Reader.h b/lib/UserInterface/textinput/Reader.h index ef7b3edb..a19350ec 100644 --- a/lib/UserInterface/textinput/Reader.h +++ b/lib/UserInterface/textinput/Reader.h @@ -38,6 +38,8 @@ namespace textinput { virtual bool HavePendingInput(bool wait) = 0; virtual bool HaveBufferedInput() const { return false; } virtual bool ReadInput(size_t& nRead, InputData& in) = 0; + + virtual bool IsFromTTY() = 0; private: TextInputContext* fContext; // Context object }; diff --git a/lib/UserInterface/textinput/StreamReaderUnix.h b/lib/UserInterface/textinput/StreamReaderUnix.h index 586b8a65..965a5eb3 100644 --- a/lib/UserInterface/textinput/StreamReaderUnix.h +++ b/lib/UserInterface/textinput/StreamReaderUnix.h @@ -36,6 +36,7 @@ namespace textinput { bool HaveBufferedInput() const { return !fReadAheadBuffer.empty(); } bool ReadInput(size_t& nRead, InputData& in); + bool IsFromTTY() override { return fIsTTY; } private: int ReadRawCharacter(); bool ProcessCSI(InputData& in); diff --git a/lib/UserInterface/textinput/StreamReaderWin.h b/lib/UserInterface/textinput/StreamReaderWin.h index 239f4617..074a52d7 100644 --- a/lib/UserInterface/textinput/StreamReaderWin.h +++ b/lib/UserInterface/textinput/StreamReaderWin.h @@ -31,6 +31,8 @@ namespace textinput { bool HavePendingInput(bool wait); bool ReadInput(size_t& nRead, InputData& in); + bool IsFromTTY() override { return fIsConsole; } + private: void HandleError(const char* Where) const; void HandleKeyEvent(unsigned char C, InputData& in);