Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.9.0
-
None
Description
Please see the attachment.
Just for reference if you are interested in the highlight code
class InputLine::TriggerHighlighter : public QSyntaxHighlighter { InputLine &input_line; public: double formatted_text_length; bool block_rehighlight = true; TriggerHighlighter(QTextDocument *d, InputLine *i) : QSyntaxHighlighter(d), input_line(*i) {} // QPlainTextEdit::keyPressEvent triggers rehighlight. // At this point trigger_lenght is not set yet. // We want to make sure that we are in contol over the rehighlights. // Also rehighlight emits QPlainTextEdit:textChanged which has to be avoided. // Intended shadowing. void rehighlight() { block_rehighlight = false; QSignalBlocker b(&input_line); // see below QSyntaxHighlighter::rehighlight(); // triggers QPlainTextEdit::textChanged! } void highlightBlock(const QString &text) override { if (block_rehighlight) return; block_rehighlight = true; formatted_text_length = 0.0; // Needed because trigger length is set async and may exceed the text length const auto highlight_length = std::min(input_line.trigger_length_, (uint)text.length()); if (highlight_length) { auto f = input_line.font(); f.setWeight(QFont::Light); f.setCapitalization(QFont::SmallCaps); QTextCharFormat fmt; fmt.setFont(f); fmt.setForeground(input_line.trigger_color_); setFormat(0, highlight_length, fmt); formatted_text_length += QFontMetricsF(f).horizontalAdvance(text.left(highlight_length)); setFormat(highlight_length, text.length() - highlight_length, input_line.palette().text().color()); } if (text.length() > highlight_length) formatted_text_length += QFontMetricsF(input_line.font()) .horizontalAdvance(text.sliced(highlight_length)); } };