diff src/ex_docmd.c @ 20474:3fe45aa3bbc5 v8.2.0791

patch 8.2.0791: a second popup window with terminal causes trouble Commit: https://github.com/vim/vim/commit/b5383b174b2436b556f76f14badb1c1f55d6d8f6 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 18 19:46:48 2020 +0200 patch 8.2.0791: a second popup window with terminal causes trouble Problem: A second popup window with terminal causes trouble. Solution: Disallow opening a second terminal-popup window. (closes https://github.com/vim/vim/issues/6101, closes #6103) Avoid defaulting to an invalid line number.
author Bram Moolenaar <Bram@vim.org>
date Mon, 18 May 2020 20:00:03 +0200
parents 2135b4641680
children 489cb75c76b6
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2918,8 +2918,12 @@ parse_cmd_address(exarg_T *eap, char **e
 	{
 	    case ADDR_LINES:
 	    case ADDR_OTHER:
-		// default is current line number
-		eap->line2 = curwin->w_cursor.lnum;
+		// Default is the cursor line number.  Avoid using an invalid
+		// line number though.
+		if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
+		    eap->line2 = curbuf->b_ml.ml_line_count;
+		else
+		    eap->line2 = curwin->w_cursor.lnum;
 		break;
 	    case ADDR_WINDOWS:
 		eap->line2 = CURRENT_WIN_NR;