microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.46k stars 29.36k forks source link

File updated externally not showing new values on VS Code #178876

Closed testIssue29 closed 1 year ago

testIssue29 commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Install home-brew
  2. Install gcc through home-brew
  3. Make a dummy folder with inp.txt and out.txt files
  4. Add them as variables to your zshrc using:
    inp= your/path/name
    out= your/path/name
  5. Inside this folder, create a dummy1 folder, inside it create a dummy2 folder and inside that create a dummy 3 folder.
  6. Write a test.cpp in dummy3 with the following code:
    
    #include <iostream>  
    #include <vector>  
    #include <set> 
    using namespace std;

void solve(){ vector res(4,0); char board[3][3]{};

for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
        cin >> board[i][j];
    }
}
set<char> s;
s.insert(board[0][0]), s.insert(board[0][1]), s.insert(board[0][2]);
res[s.size()]++;
s.clear();

s.insert(board[0][0]), s.insert(board[1][0]), s.insert(board[2][0]);
res[s.size()]++;
s.clear();

s.insert(board[0][0]), s.insert(board[1][1]), s.insert(board[2][2]);
res[s.size()]++;
s.clear();

s.insert(board[2][0]), s.insert(board[2][1]), s.insert(board[2][2]);
res[s.size()]++;
s.clear();

s.insert(board[0][2]), s.insert(board[1][2]), s.insert(board[2][2]);
res[s.size()]++;
s.clear();

s.insert(board[2][0]), s.insert(board[1][1]), s.insert(board[0][2]);
res[s.size()]++;
s.clear();

s.insert(board[1][0]), s.insert(board[1][1]), s.insert(board[1][2]);
res[s.size()]++;
s.clear();

s.insert(board[0][1]), s.insert(board[1][1]), s.insert(board[2][1]);
res[s.size()]++;
s.clear();

cerr << res[1] << endl;
cerr << res[2] << endl;
cout << res[1] << endl;
cout << res[2] << endl;
return;

};

int main(){ solve(); return 0; };

8. In inp.txt paste the following lines:

BAD FAD QAC

9. Open VS-code terminal from the dummy3 folder and type:
```g++-12 -std=c++17 -o "test" test.cpp -Wall && ./test <$inp>$out```
10. This pipes input from inp.txt and pipes it to out.txt. Your out.txt should look like this:

1 1

11. Now in inp.txt change the 'Q' in the last row to an 'A'. This should output 

1 3

And this is the correct output as can be seen by typing ```cerr << res[1] << endl << res[2] << endl;```
12. If the output is correct then switch the 'A' back to 'Q' and repeat 9. Do this for a few times till at 'A', you see:

1 1


or that out.txt is not being updated.
13. If you now open out.txt using any other editor, it will show the correct output as written in 11 but it does not update on VS Code.
bpasero commented 1 year ago

This issue could originate from a problem with file watching. Let me explain how file watching works in VSCode first and then provide some details how to get more logging data from how file watching behaves in your case.

Synopsis VSCode has different strategies for file watching depending on your workspace and setup:

If you are connected to a remote (SSH, WSL, Docker), the file watcher will run within the target file system. As such, even though you maybe on Windows where VSCode runs, if the remote is Linux, the file watcher will run in the Linux environment.

Platforms Depending on the platform you are on, file watching is differently implemented:

Specifically on Linux, watching a large folder recursively can result in VSCode consuming too many file handles. If that is the case, you will see a warning notification with instructions how to solve that.

Limitations File watching comes with a set of limitations:

Settings Please review your settings to see if maybe a folder is excluded by accident. Specifically, the files.watcherExclude setting is relevant.

Logging (local) !!! This is ONLY when you open a local workspace, for remote see below !!! We provide logging for file events when you enable verbose logging. Steps are:

image

Logging (remote) !!! This is ONLY when you open a remote workspace (WSL, Docker, SSH), for local see above !!! We provide logging for file events when you enable verbose logging. Steps are:

image

vscodenpa commented 1 year ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!