use reverse iter on value search (#5553)

This commit is contained in:
WindSoilder 2022-05-16 19:29:40 +08:00 committed by GitHub
parent 8bd68416e3
commit fc41a0f96b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -2,8 +2,6 @@ use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
// FIXME: jt: needs more work
#[ignore]
#[test]
fn row() {
Playground::setup("merge_test_1", |dirs, sandbox| {

View File

@ -660,8 +660,12 @@ impl Value {
let cols = cols.clone();
let span = *span;
if let Some(found) =
cols.iter().zip(vals.iter()).find(|x| x.0 == column_name)
// Make reverse iterate to avoid duplicate column leads to first value, actuall last value is expected.
if let Some(found) = cols
.iter()
.zip(vals.iter())
.rev()
.find(|x| x.0 == column_name)
{
current = found.1.clone();
} else if let Some(suggestion) = did_you_mean(&cols, column_name) {