File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 12
12
return
13
13
end
14
14
15
+ require "zlib"
16
+
15
17
module RubyLsp
16
18
module Tapioca
17
19
class Addon < ::RubyLsp ::Addon
@@ -24,6 +26,7 @@ def initialize
24
26
@global_state = T . let ( nil , T . nilable ( RubyLsp ::GlobalState ) )
25
27
@rails_runner_client = T . let ( nil , T . nilable ( RubyLsp ::Rails ::RunnerClient ) )
26
28
@index = T . let ( nil , T . nilable ( RubyIndexer ::Index ) )
29
+ @file_checksums = T . let ( { } , T ::Hash [ String , String ] )
27
30
end
28
31
29
32
sig { override . params ( global_state : RubyLsp ::GlobalState , outgoing_queue : Thread ::Queue ) . void }
@@ -71,6 +74,21 @@ def workspace_did_change_watched_files(changes)
71
74
path = URI ( change [ :uri ] ) . to_standardized_path
72
75
next if path . end_with? ( "_test.rb" , "_spec.rb" )
73
76
77
+ case change [ :type ]
78
+ when Constant ::FileChangeType ::CREATED , Constant ::FileChangeType ::CHANGED
79
+ content = File . read ( path )
80
+ current_checksum = Zlib . crc32 ( content ) . to_s
81
+
82
+ if change [ :type ] == Constant ::FileChangeType ::CHANGED && @file_checksums [ path ] == current_checksum
83
+ $stderr. puts "File has not changed. Skipping #{ path } "
84
+ next
85
+ end
86
+
87
+ @file_checksums [ path ] = current_checksum
88
+ when Constant ::FileChangeType ::DELETED
89
+ @file_checksums . delete ( path )
90
+ end
91
+
74
92
entries = T . must ( @index ) . entries_for ( path )
75
93
next unless entries
76
94
You can’t perform that action at this time.
0 commit comments