Skip to content

compose: Insert uploaded file link on its own line, matching web. - #2451

Open
ibrahim-iqbal wants to merge 1 commit into
zulip:mainfrom
ibrahim-iqbal:compose-upload-link-padding
Open

ibrahim-iqbal wants to merge 1 commit into
zulip:mainfrom
ibrahim-iqbal:compose-upload-link-padding

Conversation

@ibrahim-iqbal

@ibrahim-iqbal ibrahim-iqbal commented Sep 16, 2026 •

Copy link
Copy Markdown

Fixes #2227.

Previously, ComposeContentController.registerUploadStart in lib/widgets/compose_box.dart inserted an uploaded file's link placeholder at the cursor with no leading whitespace and two trailing newlines, so a placeholder would land in the middle of whatever the user had already typed on that line and push an extra blank line after itself. That does not match zulip-web, which puts the link on its own line with a single trailing newline.

Change: compute a paddingBefore from the text before the insertion point — empty when the cursor is already at the start of a line (or in an empty buffer), one newline otherwise — and use a single trailing newline instead of two.

Sample text see image: followed by an upload now becomes:

see image: 
[Uploading image.jpg…]()

instead of

see image: [Uploading image.jpg…]()

The existing widget tests in test/widgets/compose_box_test.dart under group('uploads', ...) exercise every entry point (media library on Android and iOS, camera, keyboard attach, file picker, non-ASCII filename), so their expected strings are updated in the same commit and pin the new shape.

Notes

  • Picked this up because the previous claim on Uploaded files should prepend a space or newline before [...](...) #2227 has been dormant since 2026-03-18 and zulip-flutter's README.md (via zulip.readthedocs.io) allows taking over abandoned work. Happy to hand it back if @Prince2347X is still on it.
  • Local flutter test is blocked on this Mac by the Xcode license gate (objective_c plugin's build hook shells out to xcrun --show-sdk-path), so I've relied on flutter analyze locally (clean on both touched files) and am counting on CI for the widget-test run.
  • No API surface change, and insertPadded semantics are untouched (that helper still adds the empty-line-before-and-after padding quote-and-reply blocks want); only the direct call site for uploads is updated.

@ibrahim-iqbal
ibrahim-iqbal force-pushed the compose-upload-link-padding branch from 882f79b to a4869c5 Compare September 16, 2026 11:50
@ibrahim-iqbal
ibrahim-iqbal force-pushed the compose-upload-link-padding branch from 563eea5 to 0b0f764 Compare November 2, 2026 13:00
@Ruhdee

Ruhdee commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this @ibrahim-iqbal!
Before a detailed review, please clean up the branch history:

  1. Zulip uses a rebase-based workflow with no merge commits, so rebase your commits onto main instead of merging them.
  2. Squash the two "compose test" commits into the main commit. Test updates belong in the same commit as the change they test.
  3. Drop the CI commit. It seems unrelated to the issue.

Previously, registerUploadStart inserted an uploaded file's link
placeholder at the cursor with no leading whitespace and two
trailing newlines, so a placeholder would land in the middle of
whatever the user had already typed on that line and push an
extra blank line after itself.

Match zulip-web's shape instead: one leading newline when the
insertion point isn't already at the start of a line, and a
single trailing newline. The link ends up on its own line and
the compose box does not accumulate blank lines between
consecutive uploads.

The widget tests in test/widgets/compose_box_test.dart exercise
every entry point (media library on Android and iOS, camera,
keyboard attach, file picker); their expected strings are updated
for the new shape, and a new case covers an insertion point that
is already at the start of a line.

Fixes: zulip#2227
@ibrahim-iqbal
ibrahim-iqbal force-pushed the compose-upload-link-padding branch from 682b5f4 to 76d064c Compare November 14, 2026 16:54
@ibrahim-iqbal

Copy link
Copy Markdown
Author

Thanks @Ruhdee, done:

  1. Rebased onto current main, with no merge commits.
  2. Squashed both "compose test" commits into the main commit and updated its message to describe the test changes.
  3. Dropped the CI retrigger commit.

The branch is now a single commit; the code and tests are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uploaded files should prepend a space or newline before [...](...)

2 participants