Tweak function name

ida_star
Wilfred Hughes 2021-08-28 13:11:34 +07:00
parent 32c3e9d0ca
commit 1326152232
2 changed files with 5 additions and 5 deletions

@ -416,7 +416,7 @@ impl NewlinePositions {
/// Ensure that every line in `s` has this length. Pad short lines and
/// truncate long lines.
pub fn enforce_length(s: &str, line_length: usize) -> String {
pub fn enforce_exact_length(s: &str, line_length: usize) -> String {
let mut result = String::with_capacity(s.len());
for line in s.lines() {
// TODO: use length in chars not bytes.
@ -547,13 +547,13 @@ mod tests {
#[test]
fn enforce_length_short() {
let result = enforce_length("foo\nbar\n", 5);
let result = enforce_exact_length("foo\nbar\n", 5);
assert_eq!(result, "foo \nbar \n");
}
#[test]
fn enforce_length_long() {
let result = enforce_length("foobar\nbarbaz\n", 3);
let result = enforce_exact_length("foobar\nbarbaz\n", 3);
assert_eq!(result, "foo\nbar\n");
}

@ -2,7 +2,7 @@ use atty::Stream;
use std::cmp::{max, min};
use std::collections::HashMap;
use crate::lines::{enforce_length, enforce_max_length, format_line_num, LineGroup, LineNumber};
use crate::lines::{enforce_exact_length, enforce_max_length, format_line_num, LineGroup, LineNumber};
use crate::style::apply_colors;
use crate::syntax::{aligned_lines, MatchedPos};
@ -236,7 +236,7 @@ pub fn display(
let lhs_content_width = lhs_formatted_length - lhs_column_width;
let rhs_content_width = rhs_formatted_length - rhs_column_width;
let lhs_src = enforce_length(lhs_src, lhs_content_width);
let lhs_src = enforce_exact_length(lhs_src, lhs_content_width);
let rhs_src = enforce_max_length(rhs_src, rhs_content_width);
let lhs_colored = apply_colors(&lhs_src, true, lhs_positions);
let rhs_colored = apply_colors(&rhs_src, false, rhs_positions);