From 3b3a0ec1ffc8a2ccd9b7f2dd890d752933c8ff31 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Fri, 16 May 2025 12:23:09 +0200 Subject: [PATCH] feat(windows): add text channel with preview offset for windows (#514) ![image](https://github.com/user-attachments/assets/9f8935db-82fe-4235-8584-ab8b0508b20f) --- cable/windows-channels.toml | 8 ++++++++ television/channels/cable.rs | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cable/windows-channels.toml b/cable/windows-channels.toml index c9e5455..d2b9d0f 100644 --- a/cable/windows-channels.toml +++ b/cable/windows-channels.toml @@ -4,6 +4,14 @@ name = "files" source_command = "Get-ChildItem -Recurse -File | Select-Object -ExpandProperty FullName" preview.command = "bat -n --color=always {}" +# Text +[[cable_channel]] +name = "text" +source_command = "rg . --no-heading --line-number" +preview.command = "bat -n --color=always {0}" +preview.delimiter = ":" +preview.offset = "{1}" + # Directories [[cable_channel]] name = "dirs" diff --git a/television/channels/cable.rs b/television/channels/cable.rs index 313eec8..a64140d 100644 --- a/television/channels/cable.rs +++ b/television/channels/cable.rs @@ -85,7 +85,12 @@ impl Channel { }; return Entry::new(name).with_line_number( - offset_str.parse::().unwrap(), + offset_str.parse::().unwrap_or_else(|_| { + panic!( + "Failed to parse line number from {}", + offset_str + ); + }), ); } }