aboutsummaryrefslogtreecommitdiff
path: root/src/chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/chat.cpp')
-rw-r--r--src/chat.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/chat.cpp b/src/chat.cpp
index b021a3e6b..ddce6cd75 100644
--- a/src/chat.cpp
+++ b/src/chat.cpp
@@ -229,8 +229,8 @@ void ChatBuffer::scrollBottom()
m_scroll = getBottomScrollPos();
}
-u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols,
- std::vector<ChatFormattedLine>& destination) const
+u32 ChatBuffer::formatChatLine(const ChatLine &line, u32 cols,
+ std::vector<ChatFormattedLine> &destination) const
{
u32 num_added = 0;
std::vector<ChatFormattedFragment> next_frags;
@@ -269,7 +269,10 @@ u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols,
// Very long names
hanging_indentation = 2;
}
- //EnrichedString line_text(line.text);
+ // If there are no columns remaining after the indentation (window is very
+ // narrow), we can't write anything
+ if (hanging_indentation >= cols)
+ return 0;
next_line.first = true;
// Set/use forced newline after the last frag in each line
@@ -670,7 +673,11 @@ void ChatPrompt::reformat(u32 cols)
std::wstring ChatPrompt::getVisiblePortion() const
{
- return m_prompt + getLineRef().substr(m_view, m_cols);
+ const std::wstring &line_ref = getLineRef();
+ if ((size_t)m_view >= line_ref.size())
+ return m_prompt;
+ else
+ return m_prompt + line_ref.substr(m_view, m_cols);
}
s32 ChatPrompt::getVisibleCursorPosition() const