aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/snippets/snippetparser.cpp
blob: 5d325ad8f01f28a3993be1df474124c54455b807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "snippetparser.h"

namespace TextEditor {

QString SnippetParseError::htmlMessage() const
{
    QString message = errorMessage;
    if (pos < 0 || pos > 50)
        return message;
    QString detail = text.left(50);
    if (detail != text)
        detail.append("...");
    detail.replace(QChar::Space, "&nbsp;");
    message.append("<br><code>" + detail + "<br>");
    for (int i = 0; i < pos; ++i)
        message.append("&nbsp;");
    message.append("^</code>");
    return message;
}

} // namespace TextEditor