Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn build(b: *std.Build) void {
build_options.addOption(
usize,
"expected_package_root_test_count",
if (!provider_enabled and test_filters.len == 0) 1988 else 0,
if (!provider_enabled and test_filters.len == 0) 2000 else 0,
);
const build_options_mod = build_options.createModule();

Expand Down
28 changes: 28 additions & 0 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,34 @@ available for source selections in side-by-side mode and includes the
before/after commit IDs and the selected side. Unified diff selections use
diff text. Without a selection, `Y` in a diff pane copies the current hunk.

### Wrap long lines

Press `W` to toggle line wrapping in the Changes, History, or Compare diff
view, or in Repository source text. Diff wrapping works in unified and
side-by-side layouts, including the unified layout used in narrow terminals.
Help (`?`) shows the effective key if you remap `toggle_line_wrap`.

Wrapping starts off. Each page keeps its own choice while its viewer is
retained, including file changes, reloads, and switching away and back. A
newly created viewer starts with wrapping off; Repository also resets it
when switching repositories. The choice is not saved
across restarts. With wrapping off, long lines are clipped and you can
scroll horizontally with the left/right arrows.

With wrapping on, continuation rows repeat neither line numbers nor diff
markers. Use the mouse wheel, Page Up/Down, or Ctrl+u/d/b/f to read long
wrapped lines. `j` / `k` still move between original source rows. Diff search
moves by original row and reveals its first fragment; scroll down to read a
match farther along that row. Repository search retains each matching
occurrence, including multiple matches on one line, and reveals the matching
fragment. Selection and copying use the original text,
without inserting newlines at wrap boundaries.

Tabs retain their spacing across wrap boundaries. If a character cannot
fit even on an empty row, a replacement glyph is shown so scrolling can
continue; copying still preserves the original character. A pane with no
room for text shows no fragments and restores them when widened.

### Switch repositories and branches

Press `R` from any working view to open the repository picker. Select a
Expand Down
41 changes: 37 additions & 4 deletions src/app/diff_surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,43 @@ pub const SelectionCompletionPolicy = enum {

pub const ViewOptions = struct {
line_numbers: bool = true,
line_wrap: bool = false,

pub fn toggleLineNumbers(self: *ViewOptions) void {
self.line_numbers = !self.line_numbers;
}

pub fn toggleLineWrap(self: *ViewOptions) void {
self.line_wrap = !self.line_wrap;
}
};

/// One position: OFF and ordinary rows have no independently mutable wrap state.
pub const ViewportPosition = union(enum) {
logical: usize,
wrapped: struct {
row: usize,
target: ?context.SelectedTarget,
content: ContentToken,
anchor: WrapAnchor,
},

pub fn atRow(value: usize) ViewportPosition {
return .{ .logical = value };
}

pub fn row(self: ViewportPosition) usize {
return switch (self) {
.logical => |value| value,
.wrapped => |value| value.row,
};
}
};

pub const WrapAnchor = struct {
side: ?diff_selection.Side = null,
byte: usize = 0,
tab_cell: usize = 0,
};

pub const ViewerState = struct {
Expand All @@ -73,7 +106,7 @@ pub const ViewerState = struct {
sidebar_hidden: bool = false,
sidebar_width: ?u16 = null,
sidebar_horizontal_scroll: usize = 0,
diff_scroll: usize = 0,
diff_scroll: ViewportPosition = .{ .logical = 0 },
diff_horizontal_scroll: usize = 0,
diff_cursor: diff_view_model.BodyCoordinate = .{ .metadata = 0 },
display_mode: diff_render.DisplayMode = .side_by_side,
Expand All @@ -100,8 +133,8 @@ pub const ReloadAnchor = struct {
visible_sidebar_row: usize,
diff_cursor: diff_view_model.BodyCoordinate,
diff_cursor_offset: ?usize,
diff_scroll: usize,
selection_viewport: ?selection_action.SelectionViewportAnchor = null,
diff_scroll: ViewportPosition,
selection_viewport: ?navigation.ViewportAnchor = null,
diff_horizontal_scroll: usize,
sidebar_horizontal_scroll: usize,
search_coordinate: ?diff_view_model.BodyCoordinate,
Expand Down Expand Up @@ -151,7 +184,7 @@ pub const DisplayNavigationSnapshot = struct {
selected_target: ?context.SelectedTarget,
selected_node: usize,
diff_cursor: diff_view_model.BodyCoordinate,
diff_scroll: usize,
diff_scroll: ViewportPosition,
diff_horizontal_scroll: usize,
sidebar_horizontal_scroll: usize,
search_coordinate: ?diff_view_model.BodyCoordinate,
Expand Down
3 changes: 3 additions & 0 deletions src/app/diff_surface/body_resolver.zig
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ pub const RenderProjectedBodyArgs = struct {
requested_mode: diff_render.DisplayMode,
display_mode_toggle_key: ?[]const u8 = null,
scroll: usize,
wrap_start: usize = 0,
horizontal_scroll: usize,
pane_active: bool,
line_numbers: bool,
line_wrap: bool = false,
highlighted_hunk: ?usize,
cursor_offset: ?usize,
palette: theme.Palette,
Expand Down Expand Up @@ -414,6 +416,7 @@ test "body resolver forwards render arguments and propagates renderer errors" {
.horizontal_scroll = 11,
.pane_active = false,
.line_numbers = false,
.line_wrap = false,
.highlighted_hunk = 13,
.cursor_offset = 17,
.palette = .default(),
Expand Down
1 change: 1 addition & 0 deletions src/app/diff_surface/message.zig
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ pub const Msg = union(enum) {
increase_sidebar_width,
toggle_display_mode,
toggle_line_numbers,
toggle_line_wrap,
};
Loading
Loading