Skip to content

Commit

Permalink
WIP handle repeat saves
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrocha committed Oct 18, 2024
1 parent bdcca29 commit 99c8bd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/ruby_lsp/tapioca/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def initialize

sig { override.params(global_state: RubyLsp::GlobalState, outgoing_queue: Thread::Queue).void }
def activate(global_state, outgoing_queue)
File.delete("tmp/tapioca.lock") if File.exist?("tmp/tapioca.lock")
@global_state = global_state
# TODO: Uncomment
# return unless @global_state.experimental_features
Expand Down Expand Up @@ -67,6 +68,14 @@ def workspace_did_change_watched_files(changes)
# return unless T.must(@global_state).experimental_features
return unless @rails_runner_client # Client is not ready

tapioca_lock_file = "tmp/tapioca.lock"

if File.exist?(tapioca_lock_file)
$stderr.puts "Ignoring save since Tapioca is already processing previous request"
return
end

File.write(tapioca_lock_file, "")
constants = changes.flat_map do |change|
path = URI(change[:uri]).to_standardized_path
next if path.end_with?("_test.rb", "_spec.rb")
Expand Down
1 change: 1 addition & 0 deletions lib/ruby_lsp/tapioca/server_addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def execute(request, params)
case request
when "dsl"
dsl(params)
File.delete("tmp/tapioca.lock")
end
end

Expand Down

0 comments on commit 99c8bd8

Please sign in to comment.