Code Cleanup

The offending code is line-by-line equal to the completion highlited
method, so why make it duplicated? Call that method instead.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-03-19 15:23:58 -03:00 committed by Dirk Hohndel
parent 519f45416f
commit 3d83c48c49

View file

@ -140,16 +140,8 @@ void TagWidget::reparse()
void TagWidget::completionSelected(QString completion) void TagWidget::completionSelected(QString completion)
{ {
QPair<int, int> pos; completionHighlighted(completion);
pos = getCursorTagPosition(); emit textChanged();
if (pos.first >= 0 && pos.second > 0) {
setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion));
setCursorPosition(pos.first + completion.length());
} else {
setText(completion.append(", "));
setCursorPosition(text().length());
}
emit(textChanged());
} }
void TagWidget::completionHighlighted(QString completion) void TagWidget::completionHighlighted(QString completion)
@ -163,7 +155,6 @@ void TagWidget::completionHighlighted(QString completion)
setText(completion.append(", ")); setText(completion.append(", "));
setCursorPosition(text().length()); setCursorPosition(text().length());
} }
} }
void TagWidget::setCursorPosition(int position) void TagWidget::setCursorPosition(int position)