From 00f6959a29844e9c82d456ea2c32631f94013fe8 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 15 Nov 2024 23:17:27 -0800 Subject: [PATCH] Ensure JSON output is consistently ordered Closes #780 --- src/display/json.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/display/json.rs b/src/display/json.rs index f0a10498c8..122351bc92 100644 --- a/src/display/json.rs +++ b/src/display/json.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; use line_numbers::LineNumber; use serde::{ser::SerializeStruct, Serialize, Serializer}; @@ -112,7 +112,7 @@ impl<'f> From<&'f DiffResult> for File<'f> { let mut chunks = Vec::with_capacity(hunks.len()); for hunk in &hunks { - let mut lines = HashMap::with_capacity(hunk.lines.len()); + let mut lines = BTreeMap::new(); let (start_i, end_i) = matched_lines_indexes_for_hunk(matched_lines, hunk, 0); let aligned_lines = &matched_lines[start_i..end_i];