Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Bug with Bug on QML/JS Reformat File? , forEach function is deleted



  • jrrobles79@gmail.com said:

    I have the next function:

     onAdditionInfoFetched:{
                 //(var info)
                if(!isCurrentStackPage){
                    return;
                }
                var msgs = []
                info.forEach(element => {
                                 var indexOf = messagesListModel.indexOf("tdid", element.tdid)
                                 if (element.type === 0 && indexOf === -1) {
                                     msgs.push(element)
                                 }
                             } );
                root.messages = root.messages.concat(msgs)
                root.messagesChanged()
                //listView.positionViewAtEnd()
            }
    

    when I call the Tools > QML/JS > reformat file, the function is changed to this:

     onAdditionInfoFetched: {
                //(var info)
                if (!isCurrentStackPage) {
                    return
                }
                var msgs = []
                info.forEach(function element } // <= all the code inside is deleted
                var indexOf = messagesListModel.indexOf("tdid", element.tdid)
                if (element.type === 0 && indexOf === -1) {
                    msgs.push(element)
                }
            })
                root.messages = root.messages.concat(msgs)
                root.messagesChanged()
                //listView.positionViewAtEnd()
            }
    

    The inner function on the forEach is removed and is now giving me an error


Log in to reply