Terminal screen… do you mean the compile/build output? That’s only informational… as long as you’ve saved the file after editing it, PIO should use the latest code very time.
I also haven’t seen that behaviour, so that’s new / different. When you say errors, is this in the ‘problems’ section (meaning it’s IntelliSense, and possibly not updating properly) or the ‘terminal’ section (meaning it’s compile output, and a problem).
^^^ since you’re mentioning changes to platformio.ini - which always forces a full rebuild, it sounds like the former, which whilst is annoying, does not prevent anything from working correctly, as IntelliSense is not related to the compile process, and can say that there are errors when there are none. Yes? No?
I’ve just installed PlatformIO with VSCode and the first project I’ve tried (converted from Arduino) is doing exactly this.
Had an error reported after build. Clicked the link to the code in the error. Edited it. Build reports the same error, with the old text in the error message.
Intellisense does track the changes. I even wrote a line of junk in the file, and the Build process does not even see it.
Update: After closing & opening VSCode, it does appear to be working as expected now. Will update if it happens again.
Update2: Some files work fine - changes are Built. Other files in the same project do not. Closing VSCode & reloading does seem to change things. Is VSCode caching files?
When you say “Build reports the same error”, do you refer to the full log in the TERMINAL view or the error as shown in the PROBLEMS view?
And what do you mean by Build process?
Anyhow, the situation is like so:
Visual Studio Code is NOT a fully integrated development environment, and it has no plans to become one. Therefore, it loosely integrates development tools such as source code validation while typing, version control, build systems and their output etc.
As a result, IntelliSense and PlatformIO’s build system work more or less independently. Since they work on the same source code and use the same compiler settings, they should be mostly in sync, ie. all IntelliSense errors should also appear in PlatformIO’s output. (The opposite is not true as IntelliSense cannot detect linker errors.)
The PROBLEMS view is populated by messages from InelliSense and from parsing the PlatfromIO output in the TERMINAL view. Parsing is easily confused. In particular, it does not clear the old messages if you execute pio run manually in the terminal view or even in a separate terminal program. It only does so if you run via a build command (icon in status bar, action in task view etc.) from within Visual Studio Code.
To get rid of the error message, either:
build using a Build command (icon in status bar, action in task view etc.), or
I was building using the icon in the status bar, and the error was as reported in the terminal, being output during the build process. I didn’t look at the problems view, just the terminal’s build output.
I was going to see if my edits were actually saved to the files on disk, but this project appears to be building without errors now, and if I make edits to the files, it now behaves as expected.
The issue seemed to appear with 2 separate files, and the corrections to those errors were only seen by the build process after closing & restarting VSCode.
This problem persists.
I edited and built the same project using the status bar icon.
The build output appears in the console, with new errors.
I commented out the errors, and re-ran the build, and the newly generated output has the same errors.
The file saved on disk has been changed, with the erroroneous code commented out.
How is the old code persisting? Surely PlatformIO calls the arduino build process passing references to the files on disk?
Update - some further information:
My project does have an additional folder called ‘libs’ in the same folder as the src, with source code in it.
During the build, in .pio several temporary folders are created with variations on ‘libxxx’ containing the compiled .a files.
It appears that changes in the source ‘lib’ files, as compared to the ‘libxxx’, are not being detected and they are not recompiled.
It does appear running a ‘Clean’ does delete all the temporary folders, and a following Build then compiles everything correctly.
Thanks for the investigation. Can you provide the structure of the project folder (files and directories, without .pio directory)? And can you indicate to which file you’ve added the compile error for testing?