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
5 changes: 3 additions & 2 deletions crates/ui/src/input/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,15 @@ impl TextElement {
);

empty_line_number.width + LINE_NUMBER_RIGHT_MARGIN
} else if state.mode.is_code_editor() {
} else if state.mode.is_code_editor() && state.mode.is_multi_line() {
LINE_NUMBER_RIGHT_MARGIN
} else {
px(0.)
};

if state.mode.is_folding() {
line_number_width += FOLD_ICON_HITBOX_WIDTH;
// Add extra space for fold icons
line_number_width += FOLD_ICON_HITBOX_WIDTH
}

(line_number_width, line_number_len)
Expand Down
13 changes: 11 additions & 2 deletions crates/ui/src/input/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,17 @@ impl InputMode {
matches!(self, InputMode::CodeEditor { .. })
}

/// Return true if the mode is code editor and `folding: true`, `multi_line: true`.
#[inline]
pub(crate) fn is_folding(&self) -> bool {
matches!(self, InputMode::CodeEditor { folding: true, .. })
matches!(
self,
InputMode::CodeEditor {
folding: true,
multi_line: true,
..
}
)
}

#[inline]
Expand Down Expand Up @@ -182,7 +190,6 @@ impl InputMode {
}

/// Return false if the mode is not [`InputMode::CodeEditor`].
#[allow(unused)]
#[inline]
pub(super) fn line_number(&self) -> bool {
match self {
Expand Down Expand Up @@ -296,6 +303,7 @@ mod tests {
assert_eq!(mode.has_indent_guides(), true);
assert_eq!(mode.max_rows(), usize::MAX);
assert_eq!(mode.min_rows(), 1);
assert_eq!(mode.is_folding(), true);

let mode = InputMode::CodeEditor {
multi_line: false,
Expand All @@ -315,6 +323,7 @@ mod tests {
assert_eq!(mode.has_indent_guides(), false);
assert_eq!(mode.max_rows(), 1);
assert_eq!(mode.min_rows(), 1);
assert_eq!(mode.is_folding(), false);
}

#[test]
Expand Down