diff options
author | Semih Yavuz <semih.yavuz@qt.io> | 2023-05-23 15:02:50 +0200 |
---|---|---|
committer | Semih Yavuz <semih.yavuz@qt.io> | 2023-05-31 09:22:46 +0200 |
commit | 7a4175ff605d69dcafa4eb6aaf7aee3cf2620035 (patch) | |
tree | 8a7f7e7635e7af96eaf92885c54376930ec50eb2 /tests | |
parent | dc30e3859f4df146a675c367162720eae8d91982 (diff) |
qmlls: Fix TextSynchronization
The offset from a given range was incorrectly calculated in
findBlockByNumber because textblocks that are used to obtain that
position were mistakenly ignoring the newline character. This were
leading us to setting a different text than what we actually typed.
Add an extra text block if the text ends with \n.
Add a manual test but exclude it from tst_qmlformat as it is not a valid
qml document.
Fixes: QTBUG-113725
Change-Id: Ifb1b4121fd8af46df7627d986303ae67e170e50c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmlformat/tst_qmlformat.cpp | 1 | ||||
-rw-r--r-- | tests/manual/qmllsformatter/test.qml | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlformat/tst_qmlformat.cpp b/tests/auto/qml/qmlformat/tst_qmlformat.cpp index cb3206069c..48efab4b3a 100644 --- a/tests/auto/qml/qmlformat/tst_qmlformat.cpp +++ b/tests/auto/qml/qmlformat/tst_qmlformat.cpp @@ -87,6 +87,7 @@ void TestQmlformat::initTestCase() m_excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; m_excludedDirs << "doc/src/snippets/qtquick1/imports"; m_excludedDirs << "tests/manual/v4"; + m_excludedDirs << "tests/manual/qmllsformatter"; m_excludedDirs << "tests/auto/qml/ecmascripttests"; m_excludedDirs << "tests/auto/qml/qmllint"; diff --git a/tests/manual/qmllsformatter/test.qml b/tests/manual/qmllsformatter/test.qml new file mode 100644 index 0000000000..1b466ee3fd --- /dev/null +++ b/tests/manual/qmllsformatter/test.qml @@ -0,0 +1,45 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +// Start Test +// Open that test.qml file in a text editor that has a client for qmlls + +//////////////////////////////////////////////////////////// +// Test Case - 1 +// Type the following line manually + +import QtQml + +Window { + + +} + +// Then, execute "Format Document" in the text editor + +// Expected Result +import QtQml + +Window { +} + +//////////////////////////////////////////////////////////// +// Test Case - 2 +// Type the following line manually + +import QtQml + +Window { + aa a: { + } +} + +// Then, execute "Format Document" in the text editor + +// Expected Result +import QtQml + +Window { + aa: { + } +} |