pub fn condition_display_content(
    terminal_size: usize,
    _indent: usize,
    stripped_line: &str,
    mistake_range: Range,
    terminal_print_offset_left: usize,
    marker_size: usize,
) -> (String, usize, usize) {
    // if we can fit the full line in there, avoid all the work as much as possible
    if stripped_line.chars().count() + terminal_print_offset_left <= terminal_size {
        return (stripped_line.to_owned(), mistake_range.start, marker_size);
    }

    // The paddings give some space for the ` {} ...` and extra indentation and formatting:
    //
    //|---------------------------------------------------------------------------------------| terminal_size
    //|-------| padding_till_excerpt_start = indent (3+line_number_digit_count) + 2 white spaces = 7usize, for this case.
    //
    //   --> /home/tmhdev/Documents/cargo-spellcheck/src/suggestion.rs:62
    //    |
    // 62 |  Reasn of food, what's up with pie? There's strawberry pie, apple, pumpkin..
    //    |  ^^^^^
    //    | - there, Cherie, thither, or tither
    //    |
    //    |   Possible spelling mistake found.
    //
    const MAX_MISTAKE_LEN: usize = 20;

    const HEAD_DISPLAY_LEN: usize = 4;
    const TAIL_DISPLAY_LEN: usize = 4;

    const CENTER_DOTS: &str = "...";
    const LEFT_DOTS: &str = "..";
    const RIGHT_DOTS: &str = LEFT_DOTS;
    const NO_DOTS: &str = "";

    // guarantees that `marker_size` is always less than the max length.
    assert!(HEAD_DISPLAY_LEN + CENTER_DOTS.len() + TAIL_DISPLAY_LEN <= MAX_MISTAKE_LEN);

    // worst case conservative estimate, should be calculated based on `indent`
    const TOTAL_CONTEXT_CHAR_COUNT: usize = 6;

    // We will be using ranges to help doing the fitting:
    //
    // |-----------------------------------excerpt--------------------------------------|
    // |----------------------|---------misspelled_word---------|-----------------------|
    // |-----left_context-----|head_sub_range|-tail_sub_range-|-----right_context-----|
    //
    // Obs: paddings are not being considered in the illustration, but info is above.

    // Misspelled words that are too long will be shortened by ellipsizing parts of it.
    let (marker_size, shortened) = if mistake_range.len() > MAX_MISTAKE_LEN {
        let head_sub_range = Range {
            start: mistake_range.start,
            end: mistake_range.start + HEAD_DISPLAY_LEN,
        };
        let tail_sub_range = Range {
            start: mistake_range
                .end //non inclusive
                .saturating_sub(TAIL_DISPLAY_LEN),
            end: mistake_range.end,
        };

        //  too long word will be shorter as it follows:
        //            |-------------------| > MAX_MISTAKE_LEN
        //            therieeeeeeeeeeeeeeee
        //   4 chars  ^^^^   ...       ^^^^  4 chars
        //
        //  result:      ther...eeee

        let head_sub = stripped_line
            .chars()
            .skip(head_sub_range.start)
            .take(HEAD_DISPLAY_LEN)
            .collect::<String>();
        let tail_sub = stripped_line
            .chars()
            .skip(tail_sub_range.start)
            .take(TAIL_DISPLAY_LEN)
            .collect::<String>();

        let shortened = format!("{head_sub}...{tail_sub}");
        // FIXME if characters width a width of ineq of 1
        // ISSUE: https://github.com/drahnr/cargo-spellcheck/issues/145
        let marker_size = head_sub_range.len() + CENTER_DOTS.len() + tail_sub_range.len();

        (marker_size, shortened)
    } else {
        let full: String = stripped_line
            .chars()
            .skip(mistake_range.start)
            .take(mistake_range.len())
            .collect();
        (marker_size, full)
    };

    let stripped_line_len = stripped_line.chars().count();

    // full, uncut context coverage
    let left_context = Range {
        start: 0,
        end: mistake_range.start,
    };
    let right_context = Range {
        start: mistake_range.end,
        end: stripped_line_len,
    };

    let avail_space = terminal_size
        .saturating_sub(terminal_print_offset_left + marker_size + TOTAL_CONTEXT_CHAR_COUNT);

    // left and right we would like to partition the remaining space equally
    let avail_space_half = avail_space / 2usize;

    // TODO introduce a threshold, so the shortened version is not longer than than the original
    let (left_context, right_context, left_dots, right_dots) = match (
        avail_space_half > left_context.len(),
        avail_space_half > right_context.len(),
    ) {
        (true, false) => {
            // left context does not use all the capacity avail
            // allow the right context to consume the excess.
            let right_avail_space = avail_space - left_context.len();
            let rdots = if mistake_range.end + right_avail_space < stripped_line_len {
                NO_DOTS
            } else {
                RIGHT_DOTS
            };
            (
                left_context,
                Range {
                    start: right_context.end,
                    end: cmp::min(mistake_range.end + right_avail_space, stripped_line_len),
                },
                NO_DOTS,
                rdots,
            )
        }
        (false, true) => {
            // right context does not use all the capacity avail
            // allow the left context to consume the excess.
            let left_avail_space = avail_space - right_context.len();
            let ldots = if left_avail_space > left_context.end {
                NO_DOTS
            } else {
                LEFT_DOTS
            };
            (
                Range {
                    start: left_context.end.saturating_sub(left_avail_space),
                    end: left_context.end,
                },
                right_context,
                ldots,
                NO_DOTS,
            )
        }
        (false, false) => {
            // both sides have excess chars, so yield `avail_space_half` to both sides
            (
                Range {
                    start: left_context.end.saturating_sub(avail_space_half),
                    end: left_context.end,
                },
                Range {
                    start: right_context.start,
                    end: right_context.start + avail_space_half,
                },
                LEFT_DOTS,
                RIGHT_DOTS,
            )
        }
        _ => {
            // both sides are less than the allowed context, no need to modify
            (left_context, right_context, NO_DOTS, NO_DOTS)
        }
    };

    assert!(left_context.end == mistake_range.start);
    assert!(right_context.end <= stripped_line_len);
    assert!(left_context.len() + mistake_range.len() + right_context.len() <= stripped_line_len);

    let offset = left_context.len();
    let conditioned_line = format!(
        "{}{}{}{}{}",
        left_dots,
        stripped_line
            .chars()
            .skip(left_context.start + left_dots.len())
            .take(left_context.len() - left_dots.len())
            .collect::<String>(),
        shortened,
        stripped_line
            .chars()
            .skip(right_context.start)
            .take(right_context.len() - right_dots.len())
            .collect::<String>(),
        right_dots,
    );
    (conditioned_line, offset, marker_size)
}
For long lines, literal will be trimmed to display in one terminal line.
Misspelled words that are too long shall also be ellipsized.
src/suggestion.rs