diff --git a/src/tui.rs b/src/tui.rs index e2c22ffa1cba..afa8202579e2 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -2410,8 +2410,13 @@ impl<'a> Context<'a, '_> { // If the line has some indentation and the user pressed Home, // the first time it'll stop at the indentation. The second time // they press it, it'll move to the true start of the line. - let indent_end = tb.indent_end_logical_pos(); - if logical_after.x == 0 && logical_before > indent_end { + // + // If the cursor is already at the start of the line, + // we move it back to the end of the indentation. + if logical_after.x == 0 + && let indent_end = tb.indent_end_logical_pos() + && (logical_before > indent_end || logical_before.x == 0) + { if modifiers == kbmod::SHIFT { tb.selection_update_logical(indent_end); } else {