| 1 | namespace CascadeIDE.Models; |
| 2 | |
| 3 | /// <summary>Настройки палитры команд (Ctrl+Q). TOML: <c>[command_palette]</c> / вложенные таблицы.</summary> |
| 4 | public sealed class CommandPaletteSettings |
| 5 | { |
| 6 | /// <summary>Подтаблица <c>[command_palette.go_to_search]</c>.</summary> |
| 7 | public CommandPaletteGoToSearchSettings GoToSearch { get; set; } = new(); |
| 8 | } |
| 9 | |
| 10 | /// <summary>Workspace-поиск для префиксов <c>t:</c>/<c>m:</c>/<c>x:</c>; см. ADR 0112.</summary> |
| 11 | public sealed class CommandPaletteGoToSearchSettings |
| 12 | { |
| 13 | /// <summary><c>rg</c>, <c>hci</c> или <c>auto</c> (строго в нижнем регистре в TOML).</summary> |
| 14 | public string Backend { get; set; } = CommandPaletteGoToSearchBackendNormalizer.DefaultRaw; |
| 15 | } |
| 16 | |
| 17 | /// <summary>Нормализация строки <see cref="CommandPaletteGoToSearchSettings.Backend"/>.</summary> |
| 18 | public static class CommandPaletteGoToSearchBackendNormalizer |
| 19 | { |
| 20 | public const string RgRaw = "rg"; |
| 21 | public const string HciRaw = "hci"; |
| 22 | public const string AutoRaw = "auto"; |
| 23 | |
| 24 | public static string DefaultRaw => RgRaw; |
| 25 | |
| 26 | /// <returns>Эффективный вид бэкенда; не распознанные значения → <see cref="CommandPaletteGoToSearchBackendKind.Rg"/>.</returns> |
| 27 | public static CommandPaletteGoToSearchBackendKind Parse(string? raw) |
| 28 | { |
| 29 | if (string.IsNullOrWhiteSpace(raw)) |
| 30 | return CommandPaletteGoToSearchBackendKind.Rg; |
| 31 | return raw.Trim().ToLowerInvariant() switch |
| 32 | { |
| 33 | HciRaw => CommandPaletteGoToSearchBackendKind.Hci, |
| 34 | AutoRaw => CommandPaletteGoToSearchBackendKind.Auto, |
| 35 | RgRaw => CommandPaletteGoToSearchBackendKind.Rg, |
| 36 | _ => CommandPaletteGoToSearchBackendKind.Rg, |
| 37 | }; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | public enum CommandPaletteGoToSearchBackendKind |
| 42 | { |
| 43 | Rg = 0, |
| 44 | Hci = 1, |
| 45 | Auto = 2, |
| 46 | } |
| 47 | |