Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 1f639a3

Browse files
author
MikhailArkhipov
committed
Fix frequent module reloading
1 parent 4cf07fb commit 1f639a3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/LanguageServer/Impl/PathsWatcher.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ internal sealed class PathsWatcher : IDisposable {
3333

3434
public PathsWatcher(string[] paths, Action onChanged, ILogger log) {
3535
_log = log;
36-
if (paths?.Length == 0) {
36+
paths = paths.Where(p => Path.IsPathRooted(p)).ToArray() ?? Array.Empty<string>();
37+
if (paths.Length == 0) {
3738
return;
3839
}
3940

@@ -54,7 +55,8 @@ public PathsWatcher(string[] paths, Action onChanged, ILogger log) {
5455
try {
5556
var fsw = new System.IO.FileSystemWatcher(p) {
5657
IncludeSubdirectories = true,
57-
EnableRaisingEvents = true
58+
EnableRaisingEvents = true,
59+
NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName
5860
};
5961

6062
fsw.Changed += OnChanged;
@@ -84,9 +86,9 @@ private void OnChanged(object sender, FileSystemEventArgs e) {
8486

8587
private void TimerProc(object o) {
8688
lock (_lock) {
87-
if (!_changedSinceLastTick && _throttleTimer != null) {
89+
if (_changedSinceLastTick) {
8890
ThreadPool.QueueUserWorkItem(_ => _onChanged());
89-
_throttleTimer.Dispose();
91+
_throttleTimer?.Dispose();
9092
_throttleTimer = null;
9193
}
9294
_changedSinceLastTick = false;

0 commit comments

Comments
 (0)