Commit 7d716f2e authored by Sean McGivern's avatar Sean McGivern

Merge branch '17970-no-strip' into 'master'

Preserve Leading Whitespace

Closes #17970

See merge request gitlab-org/gitlab!18589
parents 78c81da8 d1186001
---
title: Prevent the slash command parser from removing leading whitespace from content that is unrelated to slash commands
merge_request: 18589
author: Jared Deckard
type: fixed
......@@ -50,7 +50,7 @@ module Gitlab
content, commands = perform_substitutions(content, commands)
[content.strip, commands]
[content.rstrip, commands]
end
private
......@@ -109,7 +109,7 @@ module Gitlab
[ ]
(?<arg>[^\n]*)
)?
(?:\n|$)
(?:\s*\n|$)
)
}mix
end
......
......@@ -1545,12 +1545,20 @@ describe QuickActions::InterpretService do
end
it 'limits to commands passed ' do
content = "/shrug\n/close"
content = "/shrug test\n/close"
text, commands = service.execute(content, issue, only: [:shrug])
expect(commands).to be_empty
expect(text).to eq("#{described_class::SHRUG}\n/close")
expect(text).to eq("test #{described_class::SHRUG}\n/close")
end
it 'preserves leading whitespace ' do
content = " - list\n\n/close\n\ntest\n\n"
text, _ = service.execute(content, issue)
expect(text).to eq(" - list\n\ntest")
end
context '/create_merge_request command' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment