Giter VIP home page Giter VIP logo

vscode-filewatcher-windows's Introduction

VS Code FileWatcher for Windows

This is the source code that compiles the VS Code FileWatcher command line executable. The FileWatcher is used in VS Code on Windows to watch on changes in a workspace by leveraging the C# FileSystemWatcher.

License

MIT

vscode-filewatcher-windows's People

Contributors

bpasero avatar joaomoreno avatar juliogold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-filewatcher-windows's Issues

Not firing events

Unfortunately I have not been able to successfully wire up VS Code's FileSystemWatcher so that events can be detected. The root issue is unclear since the underlying C# FileSystemWatcher works fine if I code up a demo app. Since I couldn't discover many examples demonstrating proper configuration and usage, I simply tried a variety of constructs...all to no avail. As I'm pushing the FileSystemWatcher Disposable into the ExtensionContext, it shouldn't get dereferenced by going out of scope before the events are fired. Hence, it's unclear why the events aren't firing.

Here's an example of various constructs I've tried:

public testFileSystemWatcher(): Disposable {
    // const pathFileExt = 'C:\\VST\\test_fileSystemWatcher.txt';
    // const pathFileExt = '**/txt';
    // const pathFileExt = '**/*.txt';
    const pathFileExt = '**\\*.txt';
    // const pathFileExt = 'C:\\VST\\test_fileSystemWatcher.txt';
    // const pathFileExt = 'C:\\VS\\VscExtensionSqlTemplateInjector\\src\\SqlTemplateGuidUtils.ts'
    // const pathFileExt = 'C:/VS/VscExtensionSqlTemplateInjector/src/SqlTemplateGuidUtils.ts'
    // const pathFileExt = '/src/SqlTemplateGuidUtils.ts'
    // const pathFileExt = '**/*.ts'
    // const pathFileExt = '**//*.ts'
    // const pathFileExt = '**\*.ts'
    // const pathFileExt = '**\\*.ts'
    const fileSystemWatcher: FileSystemWatcher = workspace.createFileSystemWatcher(pathFileExt);
    window.showInformationMessage(`Watching ${pathFileExt}`);
    
    fileSystemWatcher.onDidCreate(_ => {
        console.log(`Created ${_.fsPath}`);
    });

    fileSystemWatcher.onDidChange(_ => { 
        console.log(`Changed ${_.fsPath}`);
    });

    fileSystemWatcher.onDidDelete(_ => {
        console.log(`Deleted ${_.fsPath}`);
        fileSystemWatcher.dispose();
    });
    
    return fileSystemWatcher;
}

This C# test console fires created, changed, and deleted events:

class Program {

    static FileSystemWatcher fsw;
    static void Main(string[] args) {
        //fsw = new FileSystemWatcher(@"C:\VST\", "test_fileSystemWatcher.txt");
        fsw = new FileSystemWatcher(@"C:\VST\", "*.txt");
        fsw.EnableRaisingEvents = true;
        Console.WriteLine($"Watching path {fsw.Path}    filter {fsw.Filter}");
        fsw.Changed += (s, e) => Console.WriteLine("File changed");
        fsw.Created += (s, e) => Console.WriteLine("File created");
        fsw.Deleted += (s, e) => {
            Console.WriteLine("File deleted");
            fsw.Dispose();
        };
        Console.WriteLine("Press any key to terminate application");
        Console.ReadKey();
    }
}

In my case I would like to detect changes to a file on a path different from the VS Code workspace. However, I haven't been able to get it to detect changes to files on any path.

I wonder if there might be something else going on here such as a permissions issue. But that seems unlikely since running VS Code under an machine-Admin account doesn't resolve it either.

Windows 7: New files not automatically displayed in explorer (.NET 4.5 required)

From @gregvanl on April 7, 2016 17:37

  • VSCode Version:0.10.11 stable, 0.10.14-insiders
  • OS Version:Windows 7

Steps to Reproduce:

  1. Follow the CSS transpiling section and create a tasks.json with 'node-sass' as the command.
  2. Save tasks.json
  3. Restart VS Code
  4. Ctrl+Shift+B to Run Build Task

Rendering Complete, saving .css file...
Wrote CSS to ...

No .css file shows up in the Explorer

  1. Restart VS Code in the same folder.

Now styles.css is displayed

Copied from original issue: microsoft/vscode#5083

Missing some file changes

I have a moderately nested folder structure (7 levels or so) when I use gulp to del / copy / replace files the file list in VS Code is not updated fully. I would guess that it is updating before the operation is complete and missing some of the files (which files it shows and which it does not appears random). I have to use windows explorer to reassure myself that the files are there...

VS Code 0.10.8

File watcher fails over Samba share

From @jmm on November 23, 2015 17:13

The Explore sidebar doesn't always reflect the current state of the file system, e.g. I add a file from outside of vscode and it doesn't appear in Explore. I frequently have the same problem with Atom (which I also have running and which may be consuming all of the watches), but at least in Atom's tree view I can collapse, expand a folder via keyboard commands to get it to refresh. Is there a way to do it in vscode? If not, I pose it as a feature request. Thanks!

Copied from original issue: microsoft/vscode#506

undetected changes - unable to save

Issue Type: Bug

after updating to version 1.43.0 VS Code stopped detecting changes.
symptoms :

  • there are no open editor tab but the is a "1 UNSAVED " indicator in front of "OPEN EDITORS" in file explorer.

  • changes made to the file is not detected and you can't save changes.

-after restarting VS Code every thing works properly but after a while the issue resurface again.

-on closing VS Code or folder, VS Code prompt for "Saving Unsaved Changes" and if you click "OK" all changes are saved. but "Save All" command(from File menu) does not detect unsaved changes and does not save them.

VS Code version: Code 1.43.0 (78a4c91400152c0f27ba4d363eb56d2835f9903a, 2020-03-09T19:47:57.235Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz (4 x 3312)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.94GB (9.52GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (26)
Extension Author (truncated) Version
azds azu 2.0.220200302
path-intellisense chr 1.4.2
bracket-pair-colorizer-2 Coe 0.0.29
vscode-eslint dba 2.1.1
netcore-snippets dog 3.1.4
gitlens eam 10.2.1
prettier-vscode esb 3.20.0
beautify Hoo 1.5.0
path-autocomplete ion 1.13.3
csharpextensions jch 1.3.1
csharp ms- 1.21.14
vscode-aks-tools ms- 0.0.4
vscode-kubernetes-tools ms- 1.1.0
mssql ms- 1.9.0
azure-account ms- 0.8.8
powershell ms- 2020.3.0
debugger-for-chrome msj 4.12.6
vetur oct 0.24.0
vscode-yaml red 0.7.2
vue-vscode-snippets sdr 1.8.0
bootstrap4-vscode the 6.1.0
msbuild-project-tools tin 0.3.3
vscode-status-bar-format-toggle tom 2.0.0
vscode-icons vsc 10.0.0
vuetify-vscode vue 0.2.0
JavaScriptSnippets xab 1.7.2
to your clipboard because it was too large to send. Please paste.

Closing tab on file delete (View email source - Outlook 2013)

  • VSCode Version: Code 1.17.2 (b813d12980308015bcd2b3a2f6efa5c810c33ba5, 2017-10-16T13:59:46.104Z)
  • OS Version: Windows_NT x64 10.0.15063
  • Extensions:
Extension Author (truncated) Version
xml Dot 1.9.2
url-encode fle 1.1.0
ecdc mit 0.10.3
prettify-json moh 0.0.3
csharp ms- 1.12.1

Steps to Reproduce:

  1. Set VS Code as default app to open *.txt
  2. Open Outlook 2013 (15.0.4971.1000)
  3. Open Email in new window
  4. Go to Actions -> Other Actions -> View Source
  5. For about a second you will see the source in VS Code and then it disapears

Reproduces without extensions: Yes

There looks like there are 2 contributing factors to this issue:

  1. VS Code auto closes tab when file is deleted.
  2. VS Code doesn't keep Open handle on files, and Outlook deletes file as soon as it registers that no other app is holding it.

Comparing to other code editors:
Notepad and Notepad++ hold the handle and Outlook is not immediately deleting the file.
Notepad++ will ask you what to do if it detects that file is delted.

Isn't it possible to run a node command when file change?

I'm trying to run a node command when a certain file change. The command is:
node customTool.js

But this fails..

Error: Cannot find module 'D:\Apps\Microsoft VS Code\customTool.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at F
[error] unction.Module.runMain (internal/modul
[error] es/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:1
[error] 1 {
code: 'MODULE_NOT_FOUND',
requireStack:
[error] []

Add Windows ARM64 support

VS Code is available for Windows ARM64 natively, which results in great performance. However, CodeHelper.exe is still x86, which uses emulation on Windows ARM64, resulting in slower performance.

It'd be great if CodeHelper.exe could be made available for Windows ARM64 natively. Currently, this module targets .NET Framework 4.5, which doesn't support ARM64. Therefore, it would first need to be upgraded to .NET 5.

I'm happy to help with upgrading if the team would like that, and I have some first work done in https://github.com/dennisameling/vscode-filewatcher-windows/tree/dotnet-5, which compiles just fine. The team would need to decide which deployment model they prefer (self-contained or framework-dependent), which may have a significant impact on binary size.

CC @joaomoreno who mentioned the wish for native ARM64 binaries in microsoft/vscode#98587

Windows 7: Watcher fails for subst directories

From @DerTolleEmil on December 18, 2015 13:15

I sometimes map a drive letter to a directory using the Windows subst command. However, when I open that drive in VSCode new files (or file/folder deletions outside of the editor) will not get detected. This will also lead to an inconsistent UI when using git because git works just fine but will eventually show deletions and new files that aren't visible in the editor's folder tree.

Opening a folder that is a soft link or a directory junction (both created by mklink.exe) works fine though.

This is on Windows 7 x64 by the way.

Copied from original issue: microsoft/vscode#1450

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.