sketch folder content not valid any more

11 views
Skip to first unread message

Holger Lembke

unread,
Dec 27, 2017, 5:58:21 PM12/27/17
to devel...@arduino.cc
the sketch situation as fas as I understand it

the current implementation is in a way that you really do work with a folder that has sketch files inside. each tab has one file. one sketch has the name of the folder, that is the base sketch. if you try to open a sketch file, IDE expects to find that situation.

if the folder name is different, the editor class tries to fix it: it creates a subfolder in the files folder with the name of the file, moves the file into that folder and opens it.

this behavior derails several students and it is wrong on several ways.

- first: it does confuse the users and makes things worse for them.
     the 97.59% reason why folder and sketch names don`t match any more are due to renaming the folder to include a time stamp, version id or fix spelling errors.

- second: all tab files are left in the old folder, so it breaks the project. same goes for any other structures (data folders etc).

- third: the solution is located in the editor. that does not feel right.  

So to me the smarter solution would be to adapt the new folder name to the old sketch file.

Today I spend some time to implement a solution.
        -- that first tries to understand the situation (user will open a folder by selecting a sketch in that folder. what file is the base sketch? does is pair up, if not fix it),
        -- then verifies that the new file name from folder name gives a valid sketch name
            (if not: rename the folder so that its name is a valid sketch name) and
        -- then renames the sketch.

it passes the fixed structure to the editor, so its fix routines shall remain silent. (makes it compatible to old style).

Code is in
https://raw.githubusercontent.com/holgerlembke/Arduino-IDE/5923f3e0d26d60daadc7cfb330e3919995c630fa/app/src/processing/app/Base.java

public boolean checkAndFixSketchFolder(StringBuilder directory, StringBuilder filename)

/Github hates me, it added the entire file as a change.

 




per1234

unread,
Dec 27, 2017, 6:06:56 PM12/27/17
to Developers
On Wednesday, December 27, 2017 at 2:58:21 PM UTC-8, Holger Lembke wrote:
- second: all tab files are left in the old folder, so it breaks the project. same goes for any other structures (data folders etc).

Here is a related pull request from facchinm:
Reply all
Reply to author
Forward
0 new messages