Skip to content

Reusable editor (More)#3047

Merged
dgageot merged 2 commits into
docker:mainfrom
dgageot:reusable-editor-2
Jun 10, 2026
Merged

Reusable editor (More)#3047
dgageot merged 2 commits into
docker:mainfrom
dgageot:reusable-editor-2

Conversation

@dgageot

@dgageot dgageot commented Jun 10, 2026

Copy link
Copy Markdown
Member

No description provided.

dgageot added 2 commits June 10, 2026 10:40
… rune

ansi.TruncateLeft keeps a wide rune that straddles the cut, which
shifted the rest of the spliced line one cell to the right. Cut the
straddled rune entirely and pad its uncovered cell with a space, what
a terminal shows for a half-overwritten cell. Covered by new
spliceLine unit tests (plain/styled/wide-rune/padding cases).

Signed-off-by: David Gageot <david.gageot@docker.com>
SetRecording(false) reset the placeholder to the hardcoded default,
defeating WithPlaceholder for embedders that use recording mode. Track
the configured placeholder on the editor and restore that instead.

Signed-off-by: David Gageot <david.gageot@docker.com>
@dgageot dgageot requested a review from a team as a code owner June 10, 2026 08:40
@dgageot dgageot changed the title Reusable editor Reusable editor (More) Jun 10, 2026

@docker-agent docker-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

One LIKELY issue was found in the changed code. One finding was dismissed after analysis confirmed the arithmetic is always safe.

return e.tickRecordingDots()
}
e.textarea.Placeholder = "Type your message here…"
e.textarea.Placeholder = e.placeholder

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] SetRecording(false) overwrites the read-only placeholder with the default placeholder

The new e.placeholder field (introduced in this PR) is restored here when recording ends. However, WithReadOnly() sets e.textarea.Placeholder = "Session is read-only" directly without updating e.placeholder. As a result, if SetRecording(true) is called on a read-only editor and then SetRecording(false) is called, this line will restore e.placeholder — which holds defaultPlaceholder ("Type your message here…") rather than the read-only text — silently removing the read-only indicator from the UI.

Fix: Update WithReadOnly to also set e.placeholder:

func WithReadOnly() Option {
    return func(e *editor) {
        e.placeholder = "Session is read-only"
        e.textarea.Placeholder = "Session is read-only"
        e.textarea.KeyMap.InsertNewline.SetEnabled(false)
    }
}

@dgageot dgageot merged commit fc12e20 into docker:main Jun 10, 2026
9 checks passed
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.

3 participants