Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External tool file modifications not registered #1650

Closed
fredg1 opened this issue Jan 21, 2021 · 21 comments · Fixed by #1665
Closed

External tool file modifications not registered #1650

fredg1 opened this issue Jan 21, 2021 · 21 comments · Fixed by #1665
Assignees

Comments

@fredg1
Copy link

fredg1 commented Jan 21, 2021

Modifications made to files by something other than through the Editor seem to no longer be picked up, and don't trigger a recompiling of the file(s).

builderModified

Looks like the Java builder didn't detect the file change from external tool, and didn't recompile the class. This needs to be fixed at https://github.com/eclipse/eclipse.jdt.ls

Originally posted by @testforstephen in microsoft/vscode-java-debug#934 (comment)

@testforstephen testforstephen self-assigned this Jan 25, 2021
@rgrunber
Copy link
Contributor

rgrunber commented Feb 18, 2021

I'm able to reproduce the behaviour as well but even going back as far as 0.50.0, I wasn't able to get the classfile to update based on a change from outside the workspace (on Linux). What's the last version of the java extension for which this was working for you ?

I basically had an invisible project for which I'd add/remove a method to a source file using sed and monitor the contents of the classfile with javap. I noticed certain non-obvious actions, like selecting a symbol in the source would cause the classfile to be correctly updated but otherwise, the classfile was not updated by external changes.

I think it's worth fixing, but would be nice to know if we regressed and whether it's platform specific.

@snjeza
Copy link
Contributor

snjeza commented Feb 18, 2021

@rgrunber check the java.autobuild.enabled property. It should be true.

@rgrunber
Copy link
Contributor

@rgrunber check the java.autobuild.enabled property. It should be true.

I'm not overriding the default property value (true) and ProjectManager seems to set it correctly.

@snjeza
Copy link
Contributor

snjeza commented Feb 19, 2021

@rgrunber I can't reproduce the issue.
Is your java file placed in a source directory?

@rgrunber
Copy link
Contributor

rgrunber commented Feb 19, 2021

Yes, it was placed in the src/ folder at the top level of the invisible project folder. Here's the behaviour I'm seeing.

issue-1650-external-tool

Note that I think the server does receive a didChange(..) from the client in the case of "external" modifications, but it just doesn't seem to result in an update to the .class file.

@fredg1
Copy link
Author

fredg1 commented Feb 20, 2021

Are the extension updates logged? If not, I can't possibly recall what version I had when it was working...

All I can tell is that it was working fine around last September (2020), and I'm pretty sure I had somewhat recently updated.

@snjeza
Copy link
Contributor

snjeza commented Feb 20, 2021

@fredg1
Copy link
Author

fredg1 commented Feb 21, 2021

@rgrunber @fredg1 could you check https://github.com/snjeza/vscode-test/raw/master/java-0.76.2.vsix ?

Nope, still doesn't update :/

@snjeza
Copy link
Contributor

snjeza commented Feb 21, 2021

VS Code 0.75.0
vscode

@snjeza
Copy link
Contributor

snjeza commented Feb 21, 2021

VS Code 0.76.2
vscode0762

@snjeza
Copy link
Contributor

snjeza commented Feb 21, 2021

@fredg1 could you, please, reinstall https://github.com/snjeza/vscode-test/raw/master/java-0.76.2.vsix ?

@fredg1
Copy link
Author

fredg1 commented Feb 22, 2021

@snjeza It...worked, but it also added a new issue...

It did register the new changes, but I also noted that it forcefully saves every open editor related to your project, even with unsaved changes...

This is not to say that what you did was worthless, though, some of it did fix the problem!
What I did to see that was using a preLaunchTask

1- I have unsaved edits on one of the files from my project.
2- I go to the "run" tab and click "start debugging" on my launch configuration that contains the preLaunchTask
3- The popup "Do you want to save all editors before running the task?" appears.
4- before clicking "Don't save", I notice that the file in which I had unsaved edits ALREADY was forced to save. (This means that what you did made the popup useless)
5- I press "Don't save" anyway.
6- The preLaunchTask runs and edits one of the files from my project (different from the one that had unsaved edits).
7- I get confirmation that the edits from the preLaunchTask DID get registered.

@rgrunber
Copy link
Contributor

rgrunber commented Feb 22, 2021

The patch resolves the issue for me. Any change I make gets reflected in the classfile even before I click run, through the debug extension.

I'm not able to reproduce the issue of the save happening even when there's a prompt, but if this is behaviour introduced by the patch, then it should be fixed. I tried with setting "task.saveBeforeRun": "prompt" but the save always happens with no prompt.

@fredg1
Copy link
Author

fredg1 commented Feb 23, 2021

The patch resolves the issue for me. Any change I make gets reflected in the classfile even before I click run, through the debug extension.

I'm not able to reproduce the issue of the save happening even when there's a prompt, but if this is behaviour introduced by the patch, then it should be fixed. I tried with setting "task.saveBeforeRun": "prompt" but the save always happens with no prompt.

I did also have an untitled file open, so maybe that's it
1- the save happens first (but the untitled file can't be saved since it doesn't have anywhere to save "to")
2- the extension checks the opened editors and noticed an open file with unsaved changes, making it show the prompt (even though it doesn't change anything since the file with unsaved changes isn't linked with the project)

@snjeza
Copy link
Contributor

snjeza commented Feb 23, 2021

@fredg1 could you reproduce the issue in VS Code 0.75.0?
Could you attach your launch.json and tasks.json?

@rgrunber
Copy link
Contributor

rgrunber commented Feb 23, 2021

I did also have an untitled file open, so maybe that's it
1- the save happens first (but the untitled file can't be saved since it doesn't have anywhere to save "to")
2- the extension checks the opened editors and noticed an open file with unsaved changes, making it show the prompt (even though it doesn't change anything since the file with unsaved changes isn't linked with the project)

I'm able to reproduce this, but not the behaviour where the untitled file gets saved regardless. The behaviour (of prompting to save the untitled file) is also the same on 0.75.0 for me, so maybe this is an issue in the debug extension. It definitely would be nice to not prompt to save unrelated files.

I have a simple project with a source file, Test.java that has a main method. It can even be unsaved. I also have a .vscode/launch.json that I generated, but in particular I kept only :

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Launch Test",
            "request": "launch",
            "mainClass": "Test",
            "projectName": "test_928b4bb9"
        }
    ]
}

I create a new file, Untitled-1 (File -> New File) and add some text to it. I keep Untitiled-1 as being the selected file, switch to the run tab, and launch "Launch Test". The dialog comes up to save the file even though it would be unrelated. I'm not sure if this is caused by our plugin though.

As @snjeza mentions, it would be good to know your configuration to confirm this is the case.

@fredg1
Copy link
Author

fredg1 commented Feb 23, 2021

Code_eV3Ek8UMZS
Code_MU3mBsDAG3
Code_m0ecih7FZ5

@testforstephen
Copy link
Contributor

@rgrunber
I create a new file, Untitled-1 (File -> New File) and add some text to it. I keep Untitiled-1 as being the selected file, switch to the run tab, and launch "Launch Test". The dialog comes up to save the file even though it would be unrelated. I'm not sure if this is caused by our plugin though.

When triggering "Start Debugging" feature, VS Code will auto save the opened files. This is the default behavior of VS Code, not from debugger extension. The problem is it will show an extra save confirmation dialog if the current file is Untitled-1 file. This appears since VS Code 1.53. In VS Code 1.52, it won't pop up the dialog. Looks like VS Code did some change with the behavior in latest release.

@fredg1
Code_MU3mBsDAG3

That's because you configured a preLaunchTask in launch.json. This save behavior is controlled by user setting "task.saveBeforeRun" (Save all dirty editors before running a task). If you don't want to see the prompt dialog, you can set it to "always" or "never".

@fredg1
Copy link
Author

fredg1 commented Feb 25, 2021

That's because you configured a preLaunchTask in launch.json. This save behavior is controlled by user setting "task.saveBeforeRun" (Save all dirty editors before running a task). If you don't want to see the prompt dialog, you can set it to "always" or "never".

You don't get what happened; the prompt wasn't the issue. It was welcome, even.
Look at launch.json's header on the first and second images; the issue is that the unsaved changes in launch.json got saved automatically, before the prompt appeared. I didn't do it.

@testforstephen
Copy link
Contributor

@fredg1 Look at launch.json's header on the first and second images; the issue is that the unsaved changes in launch.json got saved automatically, before the prompt appeared. I didn't do it.

When you start debugging, VS Code will auto save launch.json. It requires to read the latest configuration from the launch.json, this is the expected behavior. I don't see there is problem with this.

@fredg1
Copy link
Author

fredg1 commented Feb 25, 2021

@fredg1 Look at launch.json's header on the first and second images; the issue is that the unsaved changes in launch.json got saved automatically, before the prompt appeared. I didn't do it.

When you start debugging, VS Code will auto save launch.json. It requires to read the latest configuration from the launch.json, this is the expected behavior. I don't see there is problem with this.

Whoops. Sorry, I didn't know. Here's an example using a .txt file instead.

Code_6Xpbvk2Dwz
Code_jRXtdqGgyR
Code_6tYYfq9jvh

You know the worst part? You pointing that out was actually a good thing, since doing the test again highlight that the issue is still not solved for when using a PreLaunchTask (as you can see in the terminal, the text printed was the non-modified text)

@testforstephen testforstephen added this to the End March 2021 milestone Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants