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
const hasSelection = selectionStart !== selectionEnd
if (!hasSelection) return
const start = value.lastIndexOf("\n", selectionStart - 1) + 1
const end = value.indexOf("\n", selectionEnd)
const adjustedSelectionEnd = value[selectionEnd - 1] === "\n" ? selectionEnd - 1 : selectionEnd
const end = value.indexOf("\n", adjustedSelectionEnd)
const endPos = end === -1 ? value.length : end
const selectedText = value.slice(start, endPos)
const lines = selectedText.split("\n")
test/system/selection_indent_test.rb
end
end
def test_tab_does_not_indent_line_after_trailing_newline_in_selection
with_settings :text_formatting => 'common_mark' do
visit '/projects/ecookbook/issues/new'
within('form#issue-form') do
text = "line1\nline2\nline3"
el = find('#issue_description')
el.click
# Select "line1\n" — selection ends at the start of line2
set_textarea_value 'issue_description', text, selection: [0, "line1\n".length]
el.send_keys(:tab)
assert_equal " line1\nline2\nline3", el.value
end
end
end
def test_shift_tab_unindents_selected_text
with_settings :text_formatting => 'common_mark' do
visit '/projects/ecookbook/issues/new'
(4-4/4)