Skip to content

[201_2977] fix: trap-state condition in insert session transition (#2977)#2980

Open
Prashant27-07 wants to merge 5 commits intoMoganLab:mainfrom
Prashant27-07:fix-2977
Open

[201_2977] fix: trap-state condition in insert session transition (#2977)#2980
Prashant27-07 wants to merge 5 commits intoMoganLab:mainfrom
Prashant27-07:fix-2977

Conversation

@Prashant27-07
Copy link
Contributor

@Prashant27-07 Prashant27-07 commented Mar 13, 2026

This PR fixes the trap-state condition that occurs during insert session transition.

The issue happens because the editor can remain in completion/input mode after generating the session completion command.

This patch explicitly resets the editor state by calling set_input_normal() before returning the completion command in session_complete_command.

This ensures the editor safely transitions back to normal mode and avoids getting stuck in an unintended input state.

What

When closing an insert session (e.g. Python session), the editor was stuck and could not transition from Insert Mode back to Normal Mode.

Why

The exit signal was not being handled correctly during the insert session transition, causing a trap-state where the program could not escape Insert Mode.

How

Fixed the session transition logic so that upon receiving an exit signal, the editor correctly exits the session and returns to Normal Mode.

How to test

  1. Open Mogan
  2. Start an interactive Python session (insert session)
  3. Try to close the session to exit
  4. The editor should now return to Normal Mode correctly

Fixes #2977

@JackYansongLi
Copy link
Contributor

Please add a documentation and a PR number, just like other PRs.

@Prashant27-07 Prashant27-07 changed the title Fix: trap-state condition in insert session transition (#2977) [201_2977] fix: trap-state condition in insert session transition (#2977) Mar 18, 2026
@Prashant27-07
Copy link
Contributor Author

@JackYansongLi Updated PR description and added devel/201_2977.md documentation. Please review.

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.

Bug Report: Trap-state Condition in Insert Session Transition

2 participants