MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / new

Method new

atomic-core/src/diff/display.rs:144–175  ·  view source on GitHub ↗

Create a new display line.

(
        status: LineStatus,
        raw: &'a [u8],
        old_line_num: Option<usize>,
        new_line_num: Option<usize>,
    )

Source from the content-addressed store, hash-verified

142impl<'a> DisplayLine<'a> {
143 /// Create a new display line.
144 fn new(
145 status: LineStatus,
146 raw: &'a [u8],
147 old_line_num: Option<usize>,
148 new_line_num: Option<usize>,
149 ) -> Self {
150 // Strip trailing newline for display
151 let (content_bytes, has_newline) = if raw.last() == Some(&b'\n') {
152 (&raw[..raw.len() - 1], true)
153 } else {
154 (raw, false)
155 };
156
157 // Also strip \r if present (CRLF)
158 let content_bytes = if content_bytes.last() == Some(&b'\r') {
159 &content_bytes[..content_bytes.len() - 1]
160 } else {
161 content_bytes
162 };
163
164 // Try to interpret as UTF-8, fall back to lossy conversion
165 let content = std::str::from_utf8(content_bytes).unwrap_or("");
166
167 Self {
168 status,
169 content,
170 raw,
171 old_line_num,
172 new_line_num,
173 has_newline,
174 }
175 }
176
177 /// Check if this line contains binary (non-UTF8) content.
178 pub fn is_binary(&self) -> bool {

Callers

nothing calls this directly

Calls 3

lastMethod · 0.80
diffFunction · 0.70
lenMethod · 0.45

Tested by

no test coverage detected