3
43
Fork
You've already forked opencode.el
16

Cannot see prompt text I'm typing #7

Closed
opened 2026年01月15日 10:52:33 +01:00 by fast-90 · 5 comments

See also the video in the other issue I posted:

I can't see the text I am typing as a prompt, but the text becomes visible when I submit the prompt. I also tried to disable my theme, but still have the same issue.

I am running Emacs 31.0.50, MacOS, opencode 1.1.21.

See also the video in the other issue I posted: <video src="/attachments/65bc7212-2518-4672-a01f-d7edb348bd02" title="Screen Recording 2026年01月15日 at 10.43.24" controls></video> I can't see the text I am typing as a prompt, but the text becomes visible when I submit the prompt. I also tried to disable my theme, but still have the same issue. I am running Emacs 31.0.50, MacOS, opencode 1.1.21.
Owner
Copy link

I display an invisible "> " prompt, as I couldn't get the prompt margin highlight to display at the last line of the buffer if there's nothing on it yet, and I think it's nice if someone copies the text out of the buffer, to have the user prompts prefixed with "> " so you can tell apart the user prompts even in plain text.

The invisible text property is supposed to be rear-nonsticky by default (meaning text inserted after it doesn't inherit the invisible property) but maybe in some emacs configurations it's different. I added it explicitly with (propertize "> " 'invisible t 'rear-nonsticky t) in dd220e4, does that fix it for you?

I display an invisible "> " prompt, as I couldn't get the prompt margin highlight to display at the last line of the buffer if there's nothing on it yet, and I think it's nice if someone copies the text out of the buffer, to have the user prompts prefixed with "> " so you can tell apart the user prompts even in plain text. The invisible text property is supposed to be rear-nonsticky by default (meaning text inserted after it doesn't inherit the invisible property) but maybe in some emacs configurations it's different. I added it explicitly with `(propertize "> " 'invisible t 'rear-nonsticky t)` in dd220e4, does that fix it for you?
Author
Copy link

@sczi wrote in #7 (comment):

I display an invisible "> " prompt, as I couldn't get the prompt margin highlight to display at the last line of the buffer if there's nothing on it yet, and I think it's nice if someone copies the text out of the buffer, to have the user prompts prefixed with "> " so you can tell apart the user prompts even in plain text.

The invisible text property is supposed to be rear-nonsticky by default (meaning text inserted after it doesn't inherit the invisible property) but maybe in some emacs configurations it's different. I added it explicitly with (propertize "> " 'invisible t 'rear-nonsticky t) in dd220e4, does that fix it for you?

I tried to use the branch with that commit but it still doesn't work, see also attached video.

@sczi wrote in https://codeberg.org/sczi/opencode.el/issues/7#issuecomment-9887960: > I display an invisible "> " prompt, as I couldn't get the prompt margin highlight to display at the last line of the buffer if there's nothing on it yet, and I think it's nice if someone copies the text out of the buffer, to have the user prompts prefixed with "> " so you can tell apart the user prompts even in plain text. > > The invisible text property is supposed to be rear-nonsticky by default (meaning text inserted after it doesn't inherit the invisible property) but maybe in some emacs configurations it's different. I added it explicitly with `(propertize "> " 'invisible t 'rear-nonsticky t)` in [`dd220e4`](/sczi/opencode.el/commit/dd220e4), does that fix it for you? I tried to use the branch with that commit but it still doesn't work, see also attached video.
Owner
Copy link

seems like the same issue @choker has, we discussed a little more in #9

seems like the same issue @choker has, we discussed a little more in #9
Owner
Copy link

I think I solved the mystery with f737510 let me know it if shows up now.

comint overrides the rear-nonsticky setting with it's own comint--prompt-rear-nonsticky list, which contains a bunch of properties but not invisible, making invisible rear-sticky, and the rest of the prompt invisible. It was working for me by accident because I'm on doom emacs which adds a doom--comint-protect-output-in-visual-modes-a advice to comint-output-filter which sets rear-nonsticky t on all output, making the invisible property rear-nonsticky again.

Compared to the other option from #9 of using display "" attribute, I slightly prefer using invisible as it is in yank-excluded-properties by default while display isn't. So if you copy and paste text from the chat buffer to another buffer, where you no longer have the margin highlight to indicate what text was the prompt, it will show the "> " to indicate what text was the prompt, while with using display that would be still hidden. Instead I fixed just by adding:
(add-to-list 'comint--prompt-rear-nonsticky 'invisible)

which I think might not be a terrible hack because docstring for comint--prompt-rear-nonsticky is "Text properties we set on the prompt and don't want to leak past it." and here we are displaying an invisible prompt, and that is a text property we don't want to leak past the prompt

I think I solved the mystery with f737510 let me know it if shows up now. comint overrides the rear-nonsticky setting with it's own `comint--prompt-rear-nonsticky` list, which contains a bunch of properties but not invisible, making invisible rear-sticky, and the rest of the prompt invisible. It was working for me by accident because I'm on doom emacs which adds a `doom--comint-protect-output-in-visual-modes-a` advice to `comint-output-filter` which sets `rear-nonsticky t` on all output, making the invisible property rear-nonsticky again. Compared to the other option from #9 of using `display ""` attribute, I slightly prefer using invisible as it is in `yank-excluded-properties` by default while `display` isn't. So if you copy and paste text from the chat buffer to another buffer, where you no longer have the margin highlight to indicate what text was the prompt, it will show the "> " to indicate what text was the prompt, while with using display that would be still hidden. Instead I fixed just by adding: `(add-to-list 'comint--prompt-rear-nonsticky 'invisible)` which I think might not be a terrible hack because docstring for `comint--prompt-rear-nonsticky` is "Text properties we set on the prompt and don't want to leak past it." and here we are displaying an invisible prompt, and that is a text property we don't want to leak past the prompt
Author
Copy link

This works now after I pulled the main branch this morning, thanks!

This works now after I pulled the main branch this morning, thanks!
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sczi/opencode.el#7
Reference in a new issue
sczi/opencode.el
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?