slint icon indicating copy to clipboard operation
slint copied to clipboard

Language server ignores `SLINT_ENABLE_EXPERIMENTAL_FEATURES`

Open Enyium opened this issue 1 year ago • 5 comments

I'm on Windows 10 and set the environment variable SLINT_ENABLE_EXPERIMENTAL_FEATURES globally to 1. But even though I terminated and restarted VS Code, the changed keyword still gives me an error (for changed-callbacks). Running $env:SLINT_ENABLE_EXPERIMENTAL_FEATURES in the VS Code PowerShell console confirms that the value is 1. cargo run also works without problems.

It would also be nice, if there'd be a non-global project-only way of ungating the feature; if possible via the file .vscode/settings.json.

Enyium avatar Aug 28 '24 03:08 Enyium

The language server doesn't ignore the SLINT_ENABLE_EXPERIMENTAL_FEATURES. What error do you get exactly?

ogoffart avatar Aug 28 '24 09:08 ogoffart

In a component:

    changed current-item => {
        root.old-item = current-item;
    }

changed has wavy red underlining:

Change callbacks are experimental and not yet implemented in this version of Slint

I have this extension installed: https://marketplace.visualstudio.com/items?itemName=Slint.slint.

Enyium avatar Aug 28 '24 14:08 Enyium

Did you log out and back in again? Better yet: Reboot.

In my experience just restarting an application is not enough to get fresh env vars on Windows (and most unixes for that matter).

hunger avatar Aug 28 '24 16:08 hunger

In my experience just restarting an application is not enough to get fresh env vars on Windows

In my experience, it is. It's about whether the process is a child process of another process. If it's not, it gets an up-to-date set of env vars from the OS. Only some software seems to be proactive: Directory Opus seems to read the set of env vars from the OS before starting a child process.

Did you log out and back in again? Better yet: Reboot.

In the meantime I rebooted, and the error is still there.

Enyium avatar Aug 28 '24 16:08 Enyium

the slint-lsp process should be a child process of vscode. I must admit i haven't tried Windows, but it does work on Linux. Is there something we should do to re-read the env variables?

That said, we could make it an actual settings or enable it by default in the nightly extension.

ogoffart avatar Aug 29 '24 05:08 ogoffart

Were you able to check why the slint-lsp process doesn't see the SLINT_ENABLE_EXPERIMENTAL_FEATURES env variable in your case?

ogoffart avatar Sep 13 '24 09:09 ogoffart

With System Informer, I detected the process of the VS Code window, then found the only child process of the subtree with slint in the name C:\Users\...\.vscode\extensions\slint.slint-1.7.2\bin\slint-lsp-x86_64-pc-windows-msvc.exe and looked at its env vars (through the process's property dialog in "Environment" tab).

There, I could see the process's env vars under the groups "Process", "User" and "System". Neither me nor ChatGPT know of a way to find out what group an env var belongs to. And since having SLINT_ENABLE_EXPERIMENTAL_FEATURES=1 defined for the system as well as for the user only displays it in the group "System" in the System Informer process property dialog, I think it simply compares the values to the system and user env vars.

Anyways, the slint....exe process does have its SLINT_ENABLE_EXPERIMENTAL_FEATURES env var set to 1, and still generates errors for changed-callbacks.

BTW: These changed-callback errors supersede other error messages since I started to use changed-callbacks in my project, deferring the other errors to build time through cargo run, and making .slint files permanently red.

Enyium avatar Sep 13 '24 16:09 Enyium

I am pretty sure we build support for experimental features into the LSP at all times, so I fully expect the 1.7.2 LSP to support this. You could try the nightly extension, that works for me... but as I said, that should not be necessary.

I have no real idea what might be going wrong here right now :-(

hunger avatar Sep 16 '24 08:09 hunger

With the nightly extension, it works (I don't get the errors anymore). Does this mean that it's only a matter of time until it also works with the regular extension? My regular extension is at v1.7.2.

Note that I may have to edit the file (like add a space) after opening the project before the error appears.

Enyium avatar Sep 16 '24 08:09 Enyium

The changed callback is planned to become stable in 1.8, so the next stable release will just work without the need to enable experimental features at all.

hunger avatar Sep 16 '24 08:09 hunger

I'm closing this as the nightly pre-1.8 fixed this already and that should have been in 1.8 that has been out for a while now.

hunger avatar Nov 28 '24 13:11 hunger