Skip to content

Entering Evil insert mode away from the buffer end after a process exits raises NotOpenForWriting #555

Description

@Vonfry

Description

When Ghostel is used from Eshell with Evil integration, entering Evil insert mode at an earlier position in the Ghostel buffer after the child process has exited causes Ghostel to try to write to the closed process channel.

The following error is displayed:

ghostel--send-encoded: ghostel: error in ghostel--encode-key: NotOpenForWriting

Steps to reproduce

  1. Start Emacs and evaluate the following configuration:

    (require 'evil)
    (require 'ghostel)
    (require 'evil-ghostel)
    (require 'eshell)
    (require 'ghostel-eshell)
    (add-hook 'ghostel-mode-hook 'evil-ghostel-mode)
    (ghostel-eshell-visual-command-mode)
    (evil-mode)
  2. Open Eshell.

  3. Run:

    ghostel codex
    
  4. After Codex has started, perform these actions in order:

    1. Type /exit.
    2. Press ESC to enter Evil normal mode.
    3. Press RET (Enter).
    4. Move the cursor upward into the initial messages near the beginning of the buffer.
    5. Wait for the Codex process to stop.
    6. Press a or i to enter Evil insert mode.

Actual behavior

Entering insert mode raises this error:

ghostel--send-encoded: ghostel: error in ghostel--encode-key: NotOpenForWriting

Workaround

Move the cursor to the end of the buffer before entering insert mode. No error occurs in that case, and pressing q closes the buffer.

Guess

Write a simple bash script

echo hello

sleep 5

echo world

After repeating the above steps, the issue isn't appeared. I guess this issue is
caused by some special escape charactels.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions