mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	Merge pull request #9926 from glacambre/fix_9889
Fix #9889: stopinsert prohibiting terminal mode
This commit is contained in:
		@@ -374,6 +374,7 @@ void terminal_enter(void)
 | 
				
			|||||||
  TerminalState state, *s = &state;
 | 
					  TerminalState state, *s = &state;
 | 
				
			||||||
  memset(s, 0, sizeof(TerminalState));
 | 
					  memset(s, 0, sizeof(TerminalState));
 | 
				
			||||||
  s->term = buf->terminal;
 | 
					  s->term = buf->terminal;
 | 
				
			||||||
 | 
					  stop_insert_mode = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Ensure the terminal is properly sized. Ideally window size management
 | 
					  // Ensure the terminal is properly sized. Ideally window size management
 | 
				
			||||||
  // code should always have resized the terminal already, but check here to
 | 
					  // code should always have resized the terminal already, but check here to
 | 
				
			||||||
@@ -435,7 +436,6 @@ void terminal_enter(void)
 | 
				
			|||||||
static int terminal_check(VimState *state)
 | 
					static int terminal_check(VimState *state)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (stop_insert_mode) {
 | 
					  if (stop_insert_mode) {
 | 
				
			||||||
    stop_insert_mode = false;
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return 1;
 | 
					  return 1;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,6 +106,15 @@ describe(':terminal', function()
 | 
				
			|||||||
    command('stopinsert')
 | 
					    command('stopinsert')
 | 
				
			||||||
    eq({ blocking=false, mode='n' }, nvim('get_mode'))
 | 
					    eq({ blocking=false, mode='n' }, nvim('get_mode'))
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
 | 
				
			||||||
 | 
					    command(':terminal')
 | 
				
			||||||
 | 
					    eq({ blocking=false, mode='n' }, nvim('get_mode'))
 | 
				
			||||||
 | 
					    command(':stopinsert')
 | 
				
			||||||
 | 
					    eq({ blocking=false, mode='n' }, nvim('get_mode'))
 | 
				
			||||||
 | 
					    feed('a')
 | 
				
			||||||
 | 
					    eq({ blocking=false, mode='t' }, nvim('get_mode'))
 | 
				
			||||||
 | 
					  end)
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe(':terminal (with fake shell)', function()
 | 
					describe(':terminal (with fake shell)', function()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user