@native-sdk/cli 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/build.zig +65 -91
  2. package/package.json +9 -9
  3. package/packages/core/package-lock.json +2 -2
  4. package/packages/core/package.json +1 -1
  5. package/packages/core/sdk/text.ts +25 -14
  6. package/packages/core/src/checker.ts +39 -0
  7. package/packages/core/src/emitter.ts +125 -1
  8. package/skill-data/native-ui/SKILL.md +9 -7
  9. package/src/platform/macos/appkit_host.m +25 -1
  10. package/src/platform/macos/cef_host.mm +24 -2
  11. package/src/platform/macos/root.zig +13 -0
  12. package/src/primitives/canvas/code.zig +451 -33
  13. package/src/primitives/canvas/code_tests.zig +855 -5
  14. package/src/primitives/canvas/events.zig +111 -1
  15. package/src/primitives/canvas/markdown_tests.zig +17 -18
  16. package/src/primitives/canvas/root.zig +4 -0
  17. package/src/primitives/canvas/text.zig +6 -0
  18. package/src/primitives/canvas/ui.zig +108 -29
  19. package/src/primitives/canvas/ui_markup.zig +23 -9
  20. package/src/primitives/canvas/ui_markup_compiled.zig +13 -0
  21. package/src/primitives/canvas/ui_markup_compiled_tests.zig +12 -0
  22. package/src/primitives/canvas/ui_markup_contract.zig +8 -1
  23. package/src/primitives/canvas/ui_markup_view.zig +16 -0
  24. package/src/primitives/canvas/ui_markup_view_tests.zig +71 -5
  25. package/src/primitives/canvas/ui_schema.zig +13 -0
  26. package/src/primitives/canvas/ui_schema_tests.zig +9 -7
  27. package/src/primitives/canvas/ui_tests.zig +26 -0
  28. package/src/primitives/canvas/widget_invalidation.zig +1 -0
  29. package/src/primitives/canvas/widget_metrics.zig +10 -5
  30. package/src/primitives/canvas/widget_render.zig +660 -39
  31. package/src/primitives/canvas/widget_render_controls.zig +4 -4
  32. package/src/primitives/canvas/widget_runtime.zig +2 -0
  33. package/src/primitives/canvas/widget_text_input.zig +165 -8
  34. package/src/primitives/canvas/widget_tree.zig +6 -5
  35. package/src/primitives/canvas/widgets.zig +25 -0
  36. package/src/runtime/canvas_budget_edge_tests.zig +3 -2
  37. package/src/runtime/canvas_limits.zig +13 -6
  38. package/src/runtime/canvas_widget_clipboard_tests.zig +7 -4
  39. package/src/runtime/canvas_widget_context_menu.zig +7 -2
  40. package/src/runtime/canvas_widget_event_tests.zig +18 -14
  41. package/src/runtime/canvas_widget_events.zig +51 -20
  42. package/src/runtime/canvas_widget_runtime.zig +105 -4
  43. package/src/runtime/canvas_widget_scroll_driver_tests.zig +59 -0
  44. package/src/runtime/canvas_widget_split_tree_tests.zig +100 -0
  45. package/src/runtime/canvas_widget_state.zig +27 -0
  46. package/src/runtime/canvas_widget_text_tests.zig +326 -0
  47. package/src/runtime/core.zig +15 -5
  48. package/src/runtime/gpu_surface_events.zig +12 -12
  49. package/src/runtime/view.zig +54 -16
  50. package/src/runtime/view_widget_scroll.zig +48 -18
  51. package/src/runtime/view_widget_text.zig +54 -13
  52. package/src/runtime/window_view_runtime.zig +9 -0
@@ -1348,11 +1348,18 @@ const Checker = struct {
1348
1348
  try self.requireAttrKind(node, attribute, resolved.kind, &.{.string}, markup.code_source_message);
1349
1349
  continue;
1350
1350
  }
1351
- if (std.mem.eql(u8, attribute.name, "line-numbers") or std.mem.eql(u8, attribute.name, "wrap")) {
1351
+ if (std.mem.eql(u8, attribute.name, "line-numbers") or
1352
+ std.mem.eql(u8, attribute.name, "wrap") or
1353
+ std.mem.eql(u8, attribute.name, "editable"))
1354
+ {
1352
1355
  if (attribute.value.len == 0) continue;
1353
1356
  _ = try self.attrKind(node, attribute, attribute.value);
1354
1357
  continue;
1355
1358
  }
1359
+ if (std.mem.eql(u8, attribute.name, "on-input")) {
1360
+ try self.checkMessageAttr(node, attribute);
1361
+ continue;
1362
+ }
1356
1363
  if (std.mem.eql(u8, attribute.name, "width") or
1357
1364
  std.mem.eql(u8, attribute.name, "height") or
1358
1365
  std.mem.eql(u8, attribute.name, "min-width") or
@@ -829,6 +829,20 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
829
829
  options.line_numbers = try self.codeFlagAttr(scope, node, attribute);
830
830
  continue;
831
831
  }
832
+ if (std.mem.eql(u8, attribute.name, "editable")) {
833
+ options.editable = try self.codeFlagAttr(scope, node, attribute);
834
+ continue;
835
+ }
836
+ if (std.mem.eql(u8, attribute.name, "on-input")) {
837
+ const typed = markup.attrTyped(attribute);
838
+ if (typed != .message) {
839
+ return self.failNode(node, "invalid message expression: on-* takes a Msg tag (\"add\") or tag with one binding payload (\"toggle:{item.id}\")");
840
+ }
841
+ options.on_input = inputConstructor(typed.message.tag) orelse {
842
+ return self.failNode(node, "on-input tag must carry a TextInputEvent payload");
843
+ };
844
+ continue;
845
+ }
832
846
  if (std.mem.eql(u8, attribute.name, "wrap")) {
833
847
  options.wrap = try self.codeFlagAttr(scope, node, attribute);
834
848
  continue;
@@ -2036,6 +2050,8 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
2036
2050
  const msg = try self.constructMessage(scope, node, expression);
2037
2051
  if (std.mem.eql(u8, event, "press")) {
2038
2052
  options.on_press = msg;
2053
+ } else if (std.mem.eql(u8, event, "double-press")) {
2054
+ options.on_double_press = msg;
2039
2055
  } else if (std.mem.eql(u8, event, "toggle")) {
2040
2056
  options.on_toggle = msg;
2041
2057
  } else if (std.mem.eql(u8, event, "change")) {
@@ -1,5 +1,7 @@
1
1
  const std = @import("std");
2
+ const geometry = @import("geometry");
2
3
  const canvas = @import("root.zig");
4
+ const code_model = @import("code.zig");
3
5
  const markup_view = @import("ui_markup_view.zig");
4
6
 
5
7
  const testing = std.testing;
@@ -1082,7 +1084,7 @@ pub const picker_markup_source =
1082
1084
  \\ <menu-item on-press="toggle:{open_count}">Alpha</menu-item>
1083
1085
  \\ </dropdown-menu>
1084
1086
  \\ </stack>
1085
- \\ <button on-press="add" on-hold="add">Crumb</button>
1087
+ \\ <button on-press="add" on-double-press="toggle:{open_count}" on-hold="add">Crumb</button>
1086
1088
  \\</column>
1087
1089
  ;
1088
1090
 
@@ -1131,7 +1133,7 @@ test "markup binds the hover pair and makes listeners hover-hittable, never pres
1131
1133
  try testing.expect(!row.children[0].hover_msgs);
1132
1134
  }
1133
1135
 
1134
- test "markup anchors dropdown-menus and binds dismiss and hold handlers" {
1136
+ test "markup anchors dropdown-menus and binds dismiss, hold, and double-press handlers" {
1135
1137
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
1136
1138
  defer arena_state.deinit();
1137
1139
  const arena = arena_state.allocator();
@@ -1152,6 +1154,9 @@ test "markup anchors dropdown-menus and binds dismiss and hold handlers" {
1152
1154
 
1153
1155
  const crumb = tree.root.children[1];
1154
1156
  try testing.expect(tree.msgFor(crumb.id, .hold) != null);
1157
+ try testing.expectEqual(Msg.add, tree.msgForPointerClick(crumb.id, .up, 1).?);
1158
+ try testing.expectEqual(@as(u32, 0), tree.msgForPointerClick(crumb.id, .up, 2).?.toggle);
1159
+ try testing.expectEqual(Msg.add, tree.msgForPointerClick(crumb.id, .up, 3).?);
1155
1160
  // A hold handler makes the element pressable, like on-press.
1156
1161
  try testing.expect(crumb.semantics.actions.press);
1157
1162
 
@@ -1928,7 +1933,10 @@ test "markdown misuse is caught by the model-agnostic validator with positions"
1928
1933
 
1929
1934
  // ------------------------------------------------------- code component
1930
1935
 
1931
- pub const CodeMsg = union(enum) { noop };
1936
+ pub const CodeMsg = union(enum) {
1937
+ noop,
1938
+ edit: canvas.TextInputEvent,
1939
+ };
1932
1940
 
1933
1941
  pub const CodeModel = struct {
1934
1942
  snippet: []const u8 =
@@ -1938,11 +1946,12 @@ pub const CodeModel = struct {
1938
1946
  ,
1939
1947
  show_lines: bool = true,
1940
1948
  wrap_code: bool = false,
1949
+ editable_code: bool = false,
1941
1950
  count: usize = 3,
1942
1951
  };
1943
1952
 
1944
1953
  pub const code_markup_source =
1945
- \\<code source="{snippet}" language="tsx" line-numbers="{show_lines}" wrap="{wrap_code}" width="240" label="Example code" />
1954
+ \\<code source="{snippet}" language="tsx" editable="{editable_code}" on-input="edit" line-numbers="{show_lines}" wrap="{wrap_code}" width="240" label="Example code" />
1946
1955
  ;
1947
1956
 
1948
1957
  pub const CodeUi = canvas.Ui(CodeMsg);
@@ -1950,6 +1959,8 @@ pub const CodeUi = canvas.Ui(CodeMsg);
1950
1959
  pub fn handCodeView(ui: *CodeUi, model: *const CodeModel) CodeUi.Node {
1951
1960
  return ui.code(.{
1952
1961
  .language = .html,
1962
+ .editable = model.editable_code,
1963
+ .on_input = CodeUi.inputMsg(.edit),
1953
1964
  .line_numbers = model.show_lines,
1954
1965
  .wrap = model.wrap_code,
1955
1966
  .width = 240,
@@ -1977,10 +1988,56 @@ test "code markup builds the reusable component with opt-in numbers and horizont
1977
1988
  try collectIds(markup_tree.root, &markup_ids, testing.allocator);
1978
1989
  try collectIds(hand_tree.root, &hand_ids, testing.allocator);
1979
1990
  try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
1991
+ try testing.expectEqual(canvas.WidgetKind.column, markup_tree.root.kind);
1992
+ try testing.expectEqual(geometry.InsetsF{}, markup_tree.root.layout.padding);
1993
+ try testing.expect(markup_tree.root.style.background == null);
1994
+ try testing.expect(markup_tree.root.style.border == null);
1995
+ try testing.expect(markup_tree.root.style.radius == null);
1980
1996
  try testing.expectEqual(canvas.ScrollAxes.horizontal, findByKind(markup_tree.root, .scroll_view).?.scroll_axes);
1981
1997
  const source = findByText(markup_tree.root, .text, model.snippet).?;
1982
1998
  try testing.expectEqual(@as(u8, 1), source.code_line_number_digits);
1983
1999
  try testing.expectEqualStrings("Example code", markup_tree.root.semantics.label);
2000
+
2001
+ var editable_model = model;
2002
+ editable_model.editable_code = true;
2003
+ var editable_ui = CodeUi.init(arena);
2004
+ const editable_tree = try editable_ui.finalize(try view.build(&editable_ui, &editable_model));
2005
+ try testing.expectEqual(canvas.WidgetKind.textarea, editable_tree.root.kind);
2006
+ try testing.expect(editable_tree.root.code_editor);
2007
+ try testing.expectEqual(@as(usize, 1), editable_tree.root.spans.len);
2008
+ try testing.expectEqual(code_model.Language.tsx, editable_tree.root.code_language);
2009
+ try testing.expect(editable_tree.root.text_no_wrap);
2010
+ try testing.expect(canvas.widgetScrollsAxis(editable_tree.root, .horizontal));
2011
+ try testing.expect(canvas.widgetScrollsAxis(editable_tree.root, .vertical));
2012
+ try testing.expectEqual(geometry.InsetsF{}, editable_tree.root.layout.padding);
2013
+ try testing.expect(editable_tree.root.style.background == null);
2014
+ try testing.expect(editable_tree.root.style.border == null);
2015
+ try testing.expect(editable_tree.root.style.radius == null);
2016
+ try testing.expect(editable_tree.root.semantics.actions.set_text);
2017
+ const edit = editable_tree.msgForTextEdit(editable_tree.root.id, .{ .insert_text = "x" }).?;
2018
+ try testing.expectEqualStrings("x", edit.edit.insert_text);
2019
+ }
2020
+
2021
+ test "code markup accepts lexer aliases from the shared language registry" {
2022
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
2023
+ defer arena_state.deinit();
2024
+ const arena = arena_state.allocator();
2025
+ const model = CodeModel{};
2026
+ const CodeMarkup = markup_view.MarkupView(CodeModel, CodeMsg);
2027
+ const cases = [_][]const u8{
2028
+ "<code source=\"{snippet}\" language=\"mjs\" />",
2029
+ "<code source=\"{snippet}\" language=\"yaml\" />",
2030
+ "<code source=\"{snippet}\" language=\"yml\" />",
2031
+ };
2032
+
2033
+ for (cases) |source| {
2034
+ var parser = canvas.ui_markup.Parser.init(arena, source);
2035
+ try testing.expectEqual(@as(?canvas.ui_markup.MarkupErrorInfo, null), canvas.ui_markup.validate(try parser.parse()));
2036
+
2037
+ var view = try CodeMarkup.init(arena, source);
2038
+ var ui = CodeUi.init(arena);
2039
+ _ = try ui.finalize(try view.build(&ui, &model));
2040
+ }
1984
2041
  }
1985
2042
 
1986
2043
  test "code markup misuse reports the component's closed contract" {
@@ -3240,6 +3297,7 @@ test "columns off grid and misshapen alignment values fail with teaching message
3240
3297
  pub const Folder = struct {
3241
3298
  id: u32,
3242
3299
  name: []const u8,
3300
+ level: u16 = 1,
3243
3301
  expanded: bool = false,
3244
3302
 
3245
3303
  fn key(folder: *const Folder) canvas.UiKey {
@@ -3268,7 +3326,7 @@ pub const pane_markup_source =
3268
3326
  \\<split value="{sidebar_fraction}" on-resize="sidebar_resized">
3269
3327
  \\ <tree label="Folders">
3270
3328
  \\ <for each="folders" key="id" as="f">
3271
- \\ <panel role="treeitem" expanded="{f.expanded}" on-press="select_folder:{f.id}" on-toggle="toggle_folder:{f.id}" label="{f.name}">
3329
+ \\ <panel role="treeitem" tree-level="{f.level}" expanded="{f.expanded}" on-press="select_folder:{f.id}" on-change="select_folder:{f.id}" on-toggle="toggle_folder:{f.id}" label="{f.name}">
3272
3330
  \\ <text>{f.name}</text>
3273
3331
  \\ </panel>
3274
3332
  \\ </for>
@@ -3291,7 +3349,9 @@ pub fn handPaneView(ui: *PaneUi, model: *const PaneModel) PaneUi.Node {
3291
3349
  fn folderRow(ui: *PaneUi, folder: *const Folder) PaneUi.Node {
3292
3350
  return ui.panel(.{
3293
3351
  .expanded = folder.expanded,
3352
+ .tree_level = folder.level,
3294
3353
  .on_press = PaneMsg{ .select_folder = folder.id },
3354
+ .on_change = PaneMsg{ .select_folder = folder.id },
3295
3355
  .on_toggle = PaneMsg{ .toggle_folder = folder.id },
3296
3356
  .semantics = .{ .role = .treeitem, .label = folder.name },
3297
3357
  }, .{
@@ -3332,8 +3392,14 @@ test "markup split and tree build the hand-written view with the divider synthes
3332
3392
  // and both the press (selection) and toggle (disclosure) handlers.
3333
3393
  const row = findByKind(markup_tree.root, .panel).?;
3334
3394
  try testing.expectEqual(canvas.WidgetRole.treeitem, row.semantics.role);
3395
+ try testing.expectEqual(@as(u16, 1), row.tree_level);
3335
3396
  try testing.expectEqual(@as(?bool, true), row.state.expanded);
3336
3397
  try testing.expectEqual(@as(u32, 1), markup_tree.msgForPointer(row.id, .up).?.select_folder);
3398
+ try testing.expectEqual(@as(u32, 1), markup_tree.msgForKeyboard(row.id, .{
3399
+ .phase = .key_down,
3400
+ .key = "arrowdown",
3401
+ .focus_moved = true,
3402
+ }).?.select_folder);
3337
3403
  try testing.expectEqual(@as(u32, 1), markup_tree.msgFor(row.id, .toggle).?.toggle_folder);
3338
3404
 
3339
3405
  // min-width lands as a floor only (no definite max).
@@ -563,6 +563,14 @@ pub const attrs = [_]AttrInfo{
563
563
  // numbers are opt-in; wrapping reuses generic attr code 16.
564
564
  .{ .code = 90, .name = "language", .class = .option, .group = .composite },
565
565
  .{ .code = 91, .name = "line-numbers", .class = .flag, .group = .composite },
566
+ // Editable code is a composite-only opt-in: the default code surface
567
+ // remains selectable/read-only, while `editable` lowers it through
568
+ // the textarea behavior with code-specific bare rendering.
569
+ .{ .code = 92, .name = "editable", .class = .flag, .group = .composite },
570
+ // Flat loop-rendered tree rows can declare their one-based logical
571
+ // hierarchy without manufacturing nested layout containers. Zero (the
572
+ // default when absent) keeps structural widget nesting as the source.
573
+ .{ .code = 93, .name = "tree-level", .class = .whole, .group = .option, .field = "tree_level" },
566
574
  };
567
575
 
568
576
  // ----------------------------------------------------------------- events
@@ -596,6 +604,11 @@ pub const events = [_]EventInfo{
596
604
  // `scrollback` back (the on-scroll reconcile shape) and render
597
605
  // honest status. Emulator internals never ride it.
598
606
  .{ .code = 13, .name = "terminal", .payload = .terminal_state, .only_on_element = "terminal" },
607
+ // Double press is the second half of the desktop select-then-act
608
+ // gesture. The first release still dispatches `press`; a release
609
+ // whose runtime-derived click count reached two dispatches this
610
+ // channel in place of a second press.
611
+ .{ .code = 14, .name = "double-press" },
599
612
  };
600
613
 
601
614
  // ------------------------------------------------------- token vocabulary
@@ -22,8 +22,8 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
22
22
  // the new fingerprint ONLY for additions; renames/renumbers are
23
23
  // schema-version-bump events, not silent edits.
24
24
  try testing.expectEqual(@as(usize, 70), schema.elements.len);
25
- try testing.expectEqual(@as(usize, 91), schema.attrs.len);
26
- try testing.expectEqual(@as(usize, 13), schema.events.len);
25
+ try testing.expectEqual(@as(usize, 93), schema.attrs.len);
26
+ try testing.expectEqual(@as(usize, 14), schema.events.len);
27
27
  // The element table runs through the span composite (64), the
28
28
  // bubble-reactions composite (65), the media surface (66), the
29
29
  // runtime-image leaf (67), the video playback composite (68), and
@@ -43,16 +43,18 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
43
43
  // autoplay (83), loop (84), and muted (85), the scroll-axis
44
44
  // attributes axis (86) and value-x (87), and the terminal
45
45
  // attributes pty (88) and scrollback (89), and the code language
46
- // (90) and line-numbers (91) declarations.
46
+ // (90), line-numbers (91), and editable-code (92) declarations,
47
+ // plus the flat disclosure-tree hierarchy level tree-level (93).
47
48
  try testing.expectEqual(
48
- @as(u64, 0x8c9311ac81d2a800),
49
+ @as(u64, 0x590814a0a23b9935),
49
50
  tableFingerprint(schema.AttrInfo, &schema.attrs),
50
51
  );
51
52
  // The event table runs through the pointer-hover containment pair
52
- // hover-enter (11) and hover-leave (12) and the terminal view-state
53
- // echo terminal (13).
53
+ // hover-enter (11) and hover-leave (12), the terminal view-state
54
+ // echo terminal (13), and the desktop gesture channel
55
+ // double-press (14).
54
56
  try testing.expectEqual(
55
- @as(u64, 0x62d715c2db7951d6),
57
+ @as(u64, 0x0cdda4a2d5a85101),
56
58
  tableFingerprint(schema.EventInfo, &schema.events),
57
59
  );
58
60
  }
@@ -321,6 +321,32 @@ test "keyboard events resolve activation and submit messages" {
321
321
  try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(checkbox.id, letter));
322
322
  }
323
323
 
324
+ test "tree keyboard navigation can select without dispatching pointer activation" {
325
+ var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
326
+ defer arena_state.deinit();
327
+
328
+ var ui = InboxUi.init(arena_state.allocator());
329
+ const tree = try ui.finalize(ui.tree(.{}, .{
330
+ ui.listItem(.{
331
+ .on_press = .add,
332
+ .on_change = .load_more,
333
+ .semantics = .{ .role = .treeitem },
334
+ }, "main.zig"),
335
+ }));
336
+ const row = tree.root.children[0];
337
+
338
+ try testing.expectEqual(Msg.add, tree.msgForPointer(row.id, .up).?);
339
+ try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(row.id, .{
340
+ .phase = .key_down,
341
+ .key = "arrowdown",
342
+ .focus_moved = true,
343
+ }).?);
344
+ try testing.expectEqual(Msg.add, tree.msgForKeyboard(row.id, .{
345
+ .phase = .key_down,
346
+ .key = "enter",
347
+ }).?);
348
+ }
349
+
324
350
  test "textarea keyboard: enter edits a newline, submit rides the primary chord" {
325
351
  var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
326
352
  defer arena_state.deinit();
@@ -269,6 +269,7 @@ fn widgetChange(previous: WidgetLayoutNode, next: WidgetLayoutNode, previous_ind
269
269
  !widgetLayoutStylesEqual(previous.widget.layout, next.widget.layout);
270
270
  const content_dirty = !std.mem.eql(u8, previous.widget.text, next.widget.text) or
271
271
  !textSpansEqual(previous.widget.spans, next.widget.spans) or
272
+ previous.widget.code_language != next.widget.code_language or
272
273
  previous.widget.static_text_group_id != next.widget.static_text_group_id or
273
274
  previous.widget.static_text_group_offset != next.widget.static_text_group_offset or
274
275
  !chartDataEqual(previous.widget.chart, next.widget.chart) or
@@ -112,14 +112,19 @@ pub fn widgetTextSpanLayoutOptions(widget: Widget, tokens: DesignTokens, max_wid
112
112
  };
113
113
  }
114
114
 
115
- /// Width reserved before a numbered code paragraph: the largest muted
116
- /// monospace marker plus the component's fixed marker-to-source gap.
117
- /// Marker bytes never live in `Widget.text`; paint selects them from a
118
- /// compile-time table.
115
+ const min_code_line_number_digits: usize = 3;
116
+
117
+ /// Width reserved before a numbered code paragraph: at least three muted
118
+ /// monospace marker columns (or the largest marker when it is wider) plus
119
+ /// the component's fixed marker-to-source gap. Marker bytes never live in
120
+ /// `Widget.text`; paint selects them from a compile-time table.
119
121
  pub fn widgetCodeLineNumberGutterWidth(widget: Widget, tokens: DesignTokens) f32 {
120
122
  if (widget.code_line_number_digits == 0) return 0;
121
123
  const zeros: [20]u8 = @splat('0');
122
- const digits = @min(@as(usize, widget.code_line_number_digits), zeros.len);
124
+ const digits = @min(
125
+ @max(@as(usize, widget.code_line_number_digits), min_code_line_number_digits),
126
+ zeros.len,
127
+ );
123
128
  return text_model.measureTextWidthForFont(
124
129
  tokens.text_measure,
125
130
  tokens.typography.mono_font_id,