1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-23 19:46:33 +03:00

Client: never call substr(CharCount, String::npos);

This commit is contained in:
Maxime Coste 2012-10-11 14:22:08 +02:00
parent c92077762c
commit 4210a17753

View File

@ -224,7 +224,7 @@ public:
if (m_cursor_pos != 0) if (m_cursor_pos != 0)
{ {
m_result = m_result.substr(0, m_cursor_pos - 1) m_result = m_result.substr(0, m_cursor_pos - 1)
+ m_result.substr(m_cursor_pos, String::npos); + m_result.substr(m_cursor_pos);
--m_cursor_pos; --m_cursor_pos;
} }
@ -239,7 +239,7 @@ public:
context.ui().menu_hide(); context.ui().menu_hide();
m_current_completion = -1; m_current_completion = -1;
m_result = m_result.substr(0, m_cursor_pos) + reg m_result = m_result.substr(0, m_cursor_pos) + reg
+ m_result.substr(m_cursor_pos, String::npos); + m_result.substr(m_cursor_pos);
m_cursor_pos += reg.char_length(); m_cursor_pos += reg.char_length();
} }
else if (key == Key(Key::Modifiers::Control, 'i') or // tab completion else if (key == Key(Key::Modifiers::Control, 'i') or // tab completion
@ -283,7 +283,7 @@ public:
std::string keystr; std::string keystr;
auto inserter = back_inserter(keystr); auto inserter = back_inserter(keystr);
utf8::dump(inserter, key.key); utf8::dump(inserter, key.key);
m_result = m_result.substr(0, m_cursor_pos) + keystr + m_result.substr(m_cursor_pos, String::npos); m_result = m_result.substr(0, m_cursor_pos) + keystr + m_result.substr(m_cursor_pos);
++m_cursor_pos; ++m_cursor_pos;
} }
context.ui().print_status(m_prompt + m_result, m_prompt.char_length() + m_cursor_pos); context.ui().print_status(m_prompt + m_result, m_prompt.char_length() + m_cursor_pos);