Tokenize file content into FileOps for display purposes. This is the **on-the-fly fallback** — when `diff`/`log`/`blame` needs semantic data but the SEMANTIC section hasn't been regenerated yet, this function tokenizes the content directly without persisting to redb. This is the same tokenization pipeline used during `record`, but standalone and stateless. # Arguments `path` - File path (for t
(path: &str, content: &[u8], encoding: Encoding)
| 392 | /// assert!(ops.line_count() > 0); |
| 393 | /// ``` |
| 394 | pub fn tokenize_content_for_display(path: &str, content: &[u8], encoding: Encoding) -> FileOps { |
| 395 | let placeholder_change_id = NodeId::new(0); |
| 396 | let mut builder = CrdtChangeBuilder::new(placeholder_change_id); |
| 397 | |
| 398 | let enc = if encoding == Encoding::Binary { |
| 399 | None |
| 400 | } else { |
| 401 | Some(encoding) |
| 402 | }; |
| 403 | |
| 404 | builder.add_file_with_content(path, content, enc); |
| 405 | |
| 406 | let result = builder.finish(); |
| 407 | let (file_ops_list, _, _) = result.into_parts(); |
| 408 | |
| 409 | // Extract the single FileOps for this file |
| 410 | file_ops_list |
| 411 | .into_iter() |
| 412 | .next() |
| 413 | .map(|builder_ops| builder_ops.into_change_ops()) |
| 414 | .unwrap_or_else(|| { |
| 415 | FileOps::create( |
| 416 | TrunkId::new(placeholder_change_id, 0), |
| 417 | path.to_string(), |
| 418 | Some(encoding), |
| 419 | ) |
| 420 | }) |
| 421 | } |
| 422 | |
| 423 | /// Detect the encoding of file content. |
| 424 | /// |