I would just like to say, that I am very grateful for the amount of time you have spent on this issue. Whether this leads to a resolution of the problem or not, it is much appreciated.
As to the deletion on saving the project, yes. I have done it a couple of times, just to be sure. If I simply save work.sublime-project (ctrl+s), I can close and open the project and everything remains when I choose Edit Project. But if I make the changes and save the project as, sublime removes part of the code. I have even tried saving as another name “work1.sublime-build” and the code is still changed in the new file, but remains the same in the old. Most peculiar.
It had gone over my head, that the name was not just something random. I looked at the LaTeXTools sublime-build file (R:\portable\sublimetext3\Data\Packages\LaTeXTools\LaTeX.sublime-build), and found the following information:
"target": "make_pdf",
"selector": "text.tex.latex",
And
"variants":
[
{
"name": "Traditional",
"builder": "traditional"
},
{
"name": "PdfLaTeX",
"builder": "traditional",
"program": "pdflatex"
},
...
{
"name": "XeLaTeX",
"builder": "traditional",
"program": "xelatex"
},
...
]
I have adjusted the project thusly:
{
"name": "XeLaTeX",
"cmd":
[
"xelatex", "$folder/tex/main.tex"
],
"selector": "text.tex.latex",
},
When I build with my main file, I get the following output:
[Compiling R:\work\tex\main.tex]
TraditionalBuilder: Engine: xelatex. Invoking latexmk... done.
No errors. Warnings:
When I press build while editing the included file, it doesn’t switch to main.tex, it just tries to build and fails on the included file:
[Compiling R:\work\tex\included\included1.tex]
TraditionalBuilder: Engine: xelatex. Invoking latexmk... done.
Errors:
Lastly, it also seems sublime ignores what is in the project about the build. It builds whatever I have chosen from the menu or the build with panel. I would expect that given the xelatex command in the project, pressing build would override whatever build system chosen in the menu, and instead building xelatex. I would also expect it to override building whatever document I was editing when pressing build, and instead building the main.tex. It behaves as I would expect, if the code it deletes when saving as was not applied or did not work.