19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/canopus/workspace/file_change_aware.rb', line 19
def poll_changes
return unless @watcher
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
return if now - @last_watch < (@watcher.backend == :native ? 0.05 : 1.0)
@last_watch = now
events = @watcher.poll
invalidate_git unless events.empty?
refresh_files unless events.empty?
notify_plugin_event("workspace/didChangeFiles", events.map { |event| {"type" => event.type.to_s, "path" => event.path} }) unless events.empty?
if events.any? { |event| File.basename(event.path) == ".editorconfig" }
invalidate_editorconfig
apply_settings
end
events.each do |event|
path = File.expand_path(event.path, @root)
buffer = @buffers[path]
next unless buffer
if event.type == :deleted
@message = "File was deleted on disk: #{event.path}"
elsif buffer.dirty?
@message = "File changed on disk; unsaved edits preserved: #{event.path}"
else
buffer.reload
end
rescue SaveConflict, SystemCallError, Error => error
@message = error.message
end
@window&.request_frame unless events.empty?
end
|