From c1f0bd638d9640987030bb1ee6ba3427c3a5e2aa Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 28 Aug 2019 14:11:25 -0700 Subject: [PATCH] Insert _at_ index, rather than before Inserting at the right index places new item *before* the index, so no need to decrement and then insert, since `insert` takes care of shifting down elements of the array. --- lib/vagrant/action/builtin/mixin_provisioners.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/vagrant/action/builtin/mixin_provisioners.rb b/lib/vagrant/action/builtin/mixin_provisioners.rb index 4f1c318cb..a5ccd93ac 100644 --- a/lib/vagrant/action/builtin/mixin_provisioners.rb +++ b/lib/vagrant/action/builtin/mixin_provisioners.rb @@ -74,7 +74,6 @@ module Vagrant idx = 0 if options[:before] idx = final_provs.each_with_index.map { |(p,o), i| i if o[:name].to_s == options[:before] }.reject(&:nil?).first - idx -= 1 unless idx == 0 final_provs.insert(idx, [p, options]) elsif options[:after] idx = final_provs.each_with_index.map { |(p,o), i| i if o[:name].to_s == options[:after] }.reject(&:nil?).first