mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	window: don't crash when closing two floats in a row
prevwin can be set to the current window. Then we can't jump to it after closing a float.
This commit is contained in:
		| @@ -2313,10 +2313,10 @@ int win_close(win_T *win, bool free_buf) | ||||
|     if (!win->w_floating) { | ||||
|       wp = frame2win(win_altframe(win, NULL)); | ||||
|     } else { | ||||
|       if (win_valid(prevwin)) { | ||||
|       if (win_valid(prevwin) && prevwin != win) { | ||||
|         wp = prevwin; | ||||
|       } else { | ||||
|         wp = curtab->tp_firstwin; | ||||
|         wp = firstwin; | ||||
|       } | ||||
|     } | ||||
|  | ||||
| @@ -2595,10 +2595,10 @@ win_free_mem ( | ||||
|     wp = winframe_remove(win, dirp, tp); | ||||
|     xfree(frp); | ||||
|   } else { | ||||
|     if (win_valid(prevwin)) { | ||||
|     if (win_valid(prevwin) && prevwin != win) { | ||||
|       wp = prevwin; | ||||
|     } else { | ||||
|       wp = curtab->tp_firstwin; | ||||
|       wp = firstwin; | ||||
|     } | ||||
|   } | ||||
|   win_free(win, tp); | ||||
|   | ||||
| @@ -2681,6 +2681,119 @@ describe('floating windows', function() | ||||
|         eq(exited, true) | ||||
|       end) | ||||
|  | ||||
|       it(':quit two floats in a row', function() | ||||
|         -- enter first float | ||||
|         feed('<c-w><c-w>') | ||||
|         -- enter second float | ||||
|         meths.open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8}) | ||||
|         if multigrid then | ||||
|           screen:expect{grid=[[ | ||||
|           ## grid 1 | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|                                                     | | ||||
|           ## grid 2 | ||||
|             x                                       | | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|           ## grid 3 | ||||
|             {1:y                   }| | ||||
|             {2:~                   }| | ||||
|           ## grid 4 | ||||
|             {1:^y                   }| | ||||
|             {2:~                   }| | ||||
|           ]], float_pos={ | ||||
|             [3] = {{id = 1001}, "NW", 1, 2, 5, true}, | ||||
|             [4] = {{id = 1002}, "NW", 1, 4, 8, true} | ||||
|           }} | ||||
|          else | ||||
|           screen:expect([[ | ||||
|             x                                       | | ||||
|             {0:~                                       }| | ||||
|             {0:~    }{1:y                   }{0:               }| | ||||
|             {0:~    }{2:~                   }{0:               }| | ||||
|             {0:~       }{1:^y                   }{0:            }| | ||||
|             {0:~       }{2:~                   }{0:            }| | ||||
|                                                     | | ||||
|           ]]) | ||||
|         end | ||||
|  | ||||
|         feed(':quit<cr>') | ||||
|         if multigrid then | ||||
|           screen:expect{grid=[[ | ||||
|           ## grid 1 | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             {5:[No Name] [+]                           }| | ||||
|             :quit                                   | | ||||
|           ## grid 2 | ||||
|             x                                       | | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|           ## grid 3 | ||||
|             {1:^y                   }| | ||||
|             {2:~                   }| | ||||
|           ]], float_pos={ | ||||
|             [3] = {{id = 1001}, "NW", 1, 2, 5, true}, | ||||
|           }} | ||||
|          else | ||||
|           screen:expect([[ | ||||
|             x                                       | | ||||
|             {0:~                                       }| | ||||
|             {0:~    }{1:^y                   }{0:               }| | ||||
|             {0:~    }{2:~                   }{0:               }| | ||||
|             {0:~                                       }| | ||||
|             {5:[No Name] [+]                           }| | ||||
|             :quit                                   | | ||||
|           ]]) | ||||
|         end | ||||
|  | ||||
|         feed(':quit<cr>') | ||||
|         if multigrid then | ||||
|           screen:expect([[ | ||||
|           ## grid 1 | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             [2:----------------------------------------]| | ||||
|             :quit                                   | | ||||
|           ## grid 2 | ||||
|             ^x                                       | | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|           ]]) | ||||
|          else | ||||
|           screen:expect([[ | ||||
|             ^x                                       | | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             {0:~                                       }| | ||||
|             :quit                                   | | ||||
|           ]]) | ||||
|         end | ||||
|  | ||||
|         eq(2, eval('1+1')) | ||||
|       end) | ||||
|  | ||||
|       it("o (:only) non-float", function() | ||||
|         feed("<c-w>o") | ||||
|         if multigrid then | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Björn Linse
					Björn Linse