summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1438
blob: 8a586bd6aadef695ade871a6dd1b81ceffe5b058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1438
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.1438
Problem:    Some commands cause trouble in a popup window.
Solution:   Add NOT_IN_POPUP_WINDOW.
Files:	    src/macros.h, src/popupwin.c, src/proto/popupwin.pro,
            src/ex_docmd.c, src/ex_cmds2.c, src/window.c,
            src/testdir/test_popupwin.vim


*** ../vim-8.1.1437/src/macros.h	2019-04-27 13:03:20.008715938 +0200
--- src/macros.h	2019-06-01 13:53:42.718288890 +0200
***************
*** 339,341 ****
--- 339,347 ----
  
  /* Wether a command index indicates a user command. */
  #define IS_USER_CMDIDX(idx) ((int)(idx) < 0)
+ 
+ #ifdef FEAT_TEXT_PROP
+ # define NOT_IN_POPUP_WINDOW not_in_popup_window()
+ #else
+ # define NOT_IN_POPUP_WINDOW 0
+ #endif
*** ../vim-8.1.1437/src/popupwin.c	2019-06-01 13:28:30.273829492 +0200
--- src/popupwin.c	2019-06-01 13:50:58.931115084 +0200
***************
*** 747,750 ****
--- 747,762 ----
  # endif
      }
  }
+ 
+     int
+ not_in_popup_window()
+ {
+     if (bt_popup(curwin->w_buffer))
+     {
+ 	emsg(_("E994: Not allowed in a popup window"));
+ 	return TRUE;
+     }
+     return FALSE;
+ }
+ 
  #endif // FEAT_TEXT_PROP
*** ../vim-8.1.1437/src/proto/popupwin.pro	2019-05-30 21:24:22.177201251 +0200
--- src/proto/popupwin.pro	2019-06-01 13:52:58.006515140 +0200
***************
*** 13,16 ****
--- 13,17 ----
  void f_popup_move(typval_T *argvars, typval_T *rettv);
  void f_popup_getpos(typval_T *argvars, typval_T *rettv);
  void f_popup_getoptions(typval_T *argvars, typval_T *rettv);
+ int not_in_popup_window(void);
  /* vim: set ft=c : */
*** ../vim-8.1.1437/src/ex_docmd.c	2019-05-28 23:08:12.060648736 +0200
--- src/ex_docmd.c	2019-06-01 14:11:47.076719587 +0200
***************
*** 5452,5457 ****
--- 5452,5459 ----
      static void
  ex_bunload(exarg_T *eap)
  {
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
      eap->errmsg = do_bufdel(
  	    eap->cmdidx == CMD_bdelete ? DOBUF_DEL
  		: eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE
***************
*** 5466,5471 ****
--- 5468,5475 ----
      static void
  ex_buffer(exarg_T *eap)
  {
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
      if (*eap->arg)
  	eap->errmsg = e_trailing;
      else
***************
*** 6768,6773 ****
--- 6772,6780 ----
  		       || eap->cmdidx == CMD_tabfind
  		       || eap->cmdidx == CMD_tabnew;
  
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
+ 
  #ifdef FEAT_GUI
      need_mouse_correct = TRUE;
  #endif
***************
*** 6895,6900 ****
--- 6902,6909 ----
  {
      int tab_number;
  
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
      switch (eap->cmdidx)
      {
  	case CMD_tabfirst:
***************
*** 7146,7151 ****
--- 7155,7162 ----
      int		need_hide;
      int		exmode_was = exmode_active;
  
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
      /*
       * ":vi" command ends Ex mode.
       */
*** ../vim-8.1.1437/src/ex_cmds2.c	2019-06-01 13:28:30.273829492 +0200
--- src/ex_cmds2.c	2019-06-01 14:12:18.060559339 +0200
***************
*** 1864,1869 ****
--- 1864,1871 ----
      char_u	*p;
      int		old_arg_idx = curwin->w_arg_idx;
  
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
      if (argn < 0 || argn >= ARGCOUNT)
      {
  	if (ARGCOUNT <= 1)
*** ../vim-8.1.1437/src/window.c	2019-05-31 17:34:44.195465656 +0200
--- src/window.c	2019-06-01 14:06:57.822214087 +0200
***************
*** 87,93 ****
  #endif
      char_u	cbuf[40];
  
!     Prenum1 = Prenum == 0 ? 1 : Prenum;
  
  #ifdef FEAT_CMDWIN
  # define CHECK_CMDWIN \
--- 87,94 ----
  #endif
      char_u	cbuf[40];
  
!     if (NOT_IN_POPUP_WINDOW)
! 	return;
  
  #ifdef FEAT_CMDWIN
  # define CHECK_CMDWIN \
***************
*** 102,107 ****
--- 103,110 ----
  # define CHECK_CMDWIN do { /**/ } while (0)
  #endif
  
+     Prenum1 = Prenum == 0 ? 1 : Prenum;
+ 
      switch (nchar)
      {
  /* split current window in two parts, horizontally */
***************
*** 732,737 ****
--- 735,743 ----
      int
  win_split(int size, int flags)
  {
+     if (NOT_IN_POPUP_WINDOW)
+ 	return FAIL;
+ 
      /* When the ":tab" modifier was used open a new tab page instead. */
      if (may_open_tabpage() == OK)
  	return OK;
***************
*** 1509,1515 ****
      win_T	*wp2;
      int		temp;
  
!     if (ONE_WINDOW)	    /* just one window */
      {
  	beep_flush();
  	return;
--- 1515,1523 ----
      win_T	*wp2;
      int		temp;
  
!     if (NOT_IN_POPUP_WINDOW)
! 	return;
!     if (ONE_WINDOW)	    // just one window
      {
  	beep_flush();
  	return;
***************
*** 2363,2368 ****
--- 2371,2379 ----
      tabpage_T   *prev_curtab = curtab;
      frame_T	*win_frame = win->w_frame->fr_parent;
  
+     if (NOT_IN_POPUP_WINDOW)
+ 	return FAIL;
+ 
      if (last_window())
      {
  	emsg(_("E444: Cannot close last window"));
***************
*** 4221,4226 ****
--- 4232,4239 ----
      win_T	*owp = curwin;
  #endif
  
+     if (NOT_IN_POPUP_WINDOW)
+ 	return;
      if (text_locked())
      {
  	beep_flush();
*** ../vim-8.1.1437/src/testdir/test_popupwin.vim	2019-05-31 17:34:44.195465656 +0200
--- src/testdir/test_popupwin.vim	2019-06-01 14:12:32.116486630 +0200
***************
*** 108,115 ****
  func Test_win_execute_closing_curwin()
    split
    let winid = popup_create('some text', {})
!   call win_execute(winid, winnr() .. "close")
!   call assert_equal(1, winnr())
    popupclear
  endfunc
  
--- 108,134 ----
  func Test_win_execute_closing_curwin()
    split
    let winid = popup_create('some text', {})
!   call assert_fails('call win_execute(winid, winnr() .. "close")', 'E994')
!   popupclear
! endfunc
! 
! func Test_win_execute_not_allowed()
!   let winid = popup_create('some text', {})
!   call assert_fails('call win_execute(winid, "split")', 'E994:')
!   call assert_fails('call win_execute(winid, "vsplit")', 'E994:')
!   call assert_fails('call win_execute(winid, "close")', 'E994:')
!   call assert_fails('call win_execute(winid, "bdelete")', 'E994:')
!   call assert_fails('call win_execute(winid, "tabnew")', 'E994:')
!   call assert_fails('call win_execute(winid, "tabnext")', 'E994:')
!   call assert_fails('call win_execute(winid, "next")', 'E994:')
!   call assert_fails('call win_execute(winid, "rewind")', 'E994:')
!   call assert_fails('call win_execute(winid, "buf")', 'E994:')
!   call assert_fails('call win_execute(winid, "edit")', 'E994:')
!   call assert_fails('call win_execute(winid, "enew")', 'E994:')
!   call assert_fails('call win_execute(winid, "wincmd x")', 'E994:')
!   call assert_fails('call win_execute(winid, "wincmd w")', 'E994:')
!   call assert_fails('call win_execute(winid, "wincmd t")', 'E994:')
!   call assert_fails('call win_execute(winid, "wincmd b")', 'E994:')
    popupclear
  endfunc
  
*** ../vim-8.1.1437/src/version.c	2019-06-01 13:28:30.273829492 +0200
--- src/version.c	2019-06-01 13:54:09.342153943 +0200
***************
*** 769,770 ****
--- 769,772 ----
  {   /* Add new patch number below this line */
+ /**/
+     1438,
  /**/

-- 
"Thou shalt not follow the Null Pointer, for at its end Chaos and
Madness lie."

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///