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.
This commit is contained in:
parent
5400af7a4a
commit
c1f0bd638d
|
@ -74,7 +74,6 @@ module Vagrant
|
||||||
idx = 0
|
idx = 0
|
||||||
if options[:before]
|
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 = 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])
|
final_provs.insert(idx, [p, options])
|
||||||
elsif options[:after]
|
elsif options[:after]
|
||||||
idx = final_provs.each_with_index.map { |(p,o), i| i if o[:name].to_s == options[:after] }.reject(&:nil?).first
|
idx = final_provs.each_with_index.map { |(p,o), i| i if o[:name].to_s == options[:after] }.reject(&:nil?).first
|
||||||
|
|
Loading…
Reference in New Issue