The "add space after nick when completing mid-sentence" option
introduced by
84381d6 left the space even if it turned out to be at
the end. Remove it again if the text hasn't changed when sending the
text.
_scrollBarsEnabled(true),
_pasteProtectionEnabled(true),
_emacsMode(false),
_scrollBarsEnabled(true),
_pasteProtectionEnabled(true),
_emacsMode(false),
_lastDocumentHeight(-1)
{
document()->setDocumentMargin(0);
_lastDocumentHeight(-1)
{
document()->setDocumentMargin(0);
-void MultiLineEdit::on_returnPressed(const QString &text)
+void MultiLineEdit::on_returnPressed(QString text)
+ if (_completionSpace && text.endsWith(" ")) {
+ text.chop(1);
+ }
+
if (!text.isEmpty()) {
foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) {
if (line.isEmpty())
if (!text.isEmpty()) {
foreach(const QString &line, text.split('\n', QString::SkipEmptyParts)) {
if (line.isEmpty())
void MultiLineEdit::on_textChanged()
{
void MultiLineEdit::on_textChanged()
{
+ _completionSpace = qMax(_completionSpace - 1, 0);
+
QString newText = text();
newText.replace("\r\n", "\n");
newText.replace('\r', '\n');
QString newText = text();
newText.replace("\r\n", "\n");
newText.replace('\r', '\n');
setTextCursor(cursor);
updateScrollBars();
}
setTextCursor(cursor);
updateScrollBars();
}
+
+
+void MultiLineEdit::addCompletionSpace()
+{
+ // Inserting the space emits textChanged, which should not disable removal
+ _completionSpace = 2;
+ insertPlainText(" ");
+}
+
inline qint32 idx() const { return _idx; }
inline bool emacsMode() const { return _emacsMode; }
inline qint32 idx() const { return _idx; }
inline bool emacsMode() const { return _emacsMode; }
+ void addCompletionSpace();
+
public slots:
void setMode(Mode mode);
void setMinHeight(int numLines);
public slots:
void setMode(Mode mode);
void setMinHeight(int numLines);
private slots:
void on_returnPressed();
private slots:
void on_returnPressed();
- void on_returnPressed(const QString &text);
+ void on_returnPressed(QString text);
void on_textChanged();
void on_documentHeightChanged(qreal height);
void on_textChanged();
void on_documentHeightChanged(qreal height);
bool _scrollBarsEnabled;
bool _pasteProtectionEnabled;
bool _emacsMode;
bool _scrollBarsEnabled;
bool _pasteProtectionEnabled;
bool _emacsMode;
QSize _sizeHint;
qreal _lastDocumentHeight;
QSize _sizeHint;
qreal _lastDocumentHeight;
_lastCompletionLength += _nickSuffix.length();
}
else if (s.addSpaceMidSentence()) {
_lastCompletionLength += _nickSuffix.length();
}
else if (s.addSpaceMidSentence()) {
- _lineEdit->insert(" ");
+ _lineEdit->addCompletionSpace();
_lastCompletionLength++;
}
_lastCompletionLength++;
}