Project

General

Profile

Feature #44061 » 0003-Fix-Tab-Shift-Tab-indenting-the-line-after-a-trailin.patch

Mizuki ISHIKAWA, 2026-06-09 01:32

View differences:

app/javascript/controllers/selection_indent_controller.js
12 12
    const hasSelection = selectionStart !== selectionEnd
13 13
    if (!hasSelection) return
14 14
    const start = value.lastIndexOf("\n", selectionStart - 1) + 1
15
    const end = value.indexOf("\n", selectionEnd)
15
    const adjustedSelectionEnd = value[selectionEnd - 1] === "\n" ? selectionEnd - 1 : selectionEnd
16
    const end = value.indexOf("\n", adjustedSelectionEnd)
16 17
    const endPos = end === -1 ? value.length : end
17 18
    const selectedText = value.slice(start, endPos)
18 19
    const lines = selectedText.split("\n")
test/system/selection_indent_test.rb
68 68
    end
69 69
  end
70 70

  
71
  def test_tab_does_not_indent_line_after_trailing_newline_in_selection
72
    with_settings :text_formatting => 'common_mark' do
73
      visit '/projects/ecookbook/issues/new'
74

  
75
      within('form#issue-form') do
76
        text = "line1\nline2\nline3"
77
        el = find('#issue_description')
78
        el.click
79
        # Select "line1\n" — selection ends at the start of line2
80
        set_textarea_value 'issue_description', text, selection: [0, "line1\n".length]
81
        el.send_keys(:tab)
82
        assert_equal "  line1\nline2\nline3", el.value
83
      end
84
    end
85
  end
86

  
71 87
  def test_shift_tab_unindents_selected_text
72 88
    with_settings :text_formatting => 'common_mark' do
73 89
      visit '/projects/ecookbook/issues/new'
(4-4/4)