Open Minnozz opened 2 years ago
The compiler is started here: https://github.com/rescript-lang/rescript-vscode/blob/b16d87a8c2f33a65001d753ff3e457baf1d77f79/server/src/server.ts#L1191-L1196 And it is killed here when there are no more open files: https://github.com/rescript-lang/rescript-vscode/blob/b16d87a8c2f33a65001d753ff3e457baf1d77f79/server/src/server.ts#L341-L364 Maybe the order in which the old file is closed and the new file is opened has changed in vscode?
I found the issue: when you open a file in vscode but don't edit it (by single clicking in the sidebar), it is shown in italics in the tab bar and wil auto-close when you open a different file. Auto-closing happens before the new file is opened, so there is a brief moment when there are 0 files open in the project.
Would you say that this behaviour is to be expected? Seems kind of borderline.
It is certainly defendable, knowing what the cause is, but also annoying. When you don't start a build and are just browsing files in this way, each new file also triggers the "Do you want to start a build"-popup again.
I think it would be fixable by destructing the state on a small timeout after the last file has been closed, that is cancelled when a new file is opened within the timeout window. This would make the logic more complex though.
I think longer term we are probably heading towards a model where that pop up does not show.
@zth what do you think?
Yeah I think we need to figure out if we really want to continue supporting running the compiler from the extension, and if we do we probably need to overhaul the experience around it.
I'd like to know if it's common to use that pop-up at all today. Maybe something to ask on the forums.
FWIW, I was under the impression that running a compiler separately from the extension would interfere with the functioning of the language server (see this question on the forum). In debugging this issue, I discovered that using the popup does nothing special compared to running the compiler manually. We might want to clarify in the docs how those two things interact and what your options are as a developer.
I think I've been running into this problem. Each time I single click on a .res file I get a "Do you want to start a build to get the freshest data?" message. As soon as I double-click on a file and have at least one open, this message stops popping up. But as soon as I close every .res file, which I do when I'm done editing some files, then the next time I open a .res I get that annoying popup again. What is the recommended workflow here? Do I need to have a build always going in watch mode? Or can I count on the extension to do my builds when necessary?
Even if I run a build -w
the extension still asks "Do you want to start a build to get the freshest data?" when I open my first .res
file. Super annoying and a very poor user experience for people just getting started with ReScript. I don't know what the solution is here but think the Getting Started docs need to explain the recommended workflow.
@zth I think the logic that relies on the existence of a .bsb.lock
is flawed, since this lockfile is very short-lived. After a successful build cycle, even in watch mode, it gets deleted which results in a build prompt despite the build being "fresh".
vscode
v1.69.2
rescript-vscodev1.5.11
Reproduce:
After starting a build via the popup:
After switching to a different file in the same project, the compiler is no longer running:
The popup to start a new build is also shown now.
strace of the
rescript build -w
process during switching: