Skip to content

Make whitespace inside selections visible #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 19, 2025
Merged
Changes from 1 commit
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
17 changes: 8 additions & 9 deletions src/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,6 @@ impl TextBuffer {
}

let mut selection_off = 0..0;
let mut selection_pos = 0..0;

// Figure out the selection range on this line, if any.
if cursor_beg.visual_pos.y == visual_line
Expand All @@ -1753,21 +1752,21 @@ impl TextBuffer {
let mut cursor = cursor_beg;

// By default, we assume the entire line is selected.
let mut selection_pos_beg = 0;
let mut selection_pos_end = COORD_TYPE_SAFE_MAX;
selection_off.start = cursor_beg.offset;
selection_off.end = cursor_end.offset;
selection_pos.start = 0;
selection_pos.end = COORD_TYPE_SAFE_MAX;

// The start of the selection is within this line. We need to update selection_beg.
if selection_beg <= cursor_end.logical_pos
&& selection_beg >= cursor_beg.logical_pos
{
cursor = self.cursor_move_to_logical_internal(
cursor,
Point { x: selection_beg.x.max(origin.x), y: selection_beg.y },
Point { x: selection_beg.x, y: selection_beg.y },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this just...

Suggested change
Point { x: selection_beg.x, y: selection_beg.y },
selection_beg,

);
selection_off.start = cursor.offset;
selection_pos.start = cursor.visual_pos.x;
selection_pos_beg = cursor.visual_pos.x;
}

// The end of the selection is within this line. We need to update selection_end.
Expand All @@ -1776,18 +1775,18 @@ impl TextBuffer {
{
cursor = self.cursor_move_to_logical_internal(
cursor,
Point { x: selection_end.x.min(origin.x + text_width), y: selection_end.y },
Point { x: selection_end.x, y: selection_end.y },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ut supra selection_end

);
selection_off.end = cursor.offset;
selection_pos.end = cursor.visual_pos.x;
selection_pos_end = cursor.visual_pos.x;
}

let left = destination.left + self.margin_width - origin.x;
let top = destination.top + y;
let rect = Rect {
left: left + selection_pos.start,
left: left + selection_pos_beg.max(origin.x),
top,
right: left + selection_pos.end,
right: left + selection_pos_end.min(origin.x + text_width),
bottom: top + 1,
};

Expand Down