After upgrading from F39 to F40 on Silverblue, I’ve encountered a problem with all my scripts, similar to the one described above. It appears that although all the files are being opened during the process, once it’s completed, only a few of the last ones are visible in the Text Editor. Typically, only the last two files are opened, sometimes four of them, and I’ve been unable to discern why some files are opened while others are not…
Notably, the same bash scripts worked perfectly on F39.
I cannot reproduce this with the gedit text editor. The issue could be specific to “Text editor” (gnome-text-editor). You could try similar scripts that open e.g. in a browser to see whether the problem also occurs with different applications on your system.
You could be right that this is an issue with flatpak. Testing with epubs, which on my system are associated with Foliate installed as a flatpak, only two of the five files were opened. It can work by inserting sleep commandsas a workaround (I used 0.3)