Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
Qt Creator 10.0.2
-
None
Description
Auto-Indentation (Ctrl+I) formats code blocks with lambdas differently than for functions, making much deeper indentations. When lambdas are nested, with longer variable names in complex code, the readability of the code drops dramatically, as everything important shifts to the right. You can see the difference in formatting with this simple example:
import QtQuick Rectangle { id: root property var callback1: function () { //Functions let i = 0; i++; Qt.callLater(function () { let j = 0; j++; [1, 2, 3].foreach(function (element) { let k = 0; k++; console.debug(element); }); }); } property var callback2: () => { //Lambdas let i = 0; i++; Qt.callLater(() => { let j = 0; j++; [1, 2, 3].foreach((element) => { let k = 0; k++; console.debug(element); }); }); } onWidthChanged: function () { //Functions let i = 0; i++; Qt.callLater(function () { let j = 0; j++; [1, 2, 3].foreach(function (element) { let k = 0; k++; console.debug(element); }); }); } onHeightChanged: () => { //Lambdas let i = 0; i++; Qt.callLater(() => { let j = 0; j++; [1, 2, 3].foreach((element) => { let k = 0; k++; console.debug(element); }); }); } }