summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0553
blob: 3957a8df131ee119a30b367faff23e623abc1232 (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0553
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.0553
Problem:    It is not easy to edit a script that was sourced.
Solution:   Add a count to ":scriptnames", so that ":script 40" edits the
            script with script ID 40.
Files:	    src/ex_cmds.h, src/ex_cmds2.c, src/testdir/test_scriptnames.vim,
            src/Make_all.mak, src/testdir/Make_all.mak, runtime/doc/repeat.txt


*** ../vim-8.1.0552/src/ex_cmds.h	2018-10-19 22:35:04.885189994 +0200
--- src/ex_cmds.h	2018-11-30 22:16:01.339155261 +0100
***************
*** 62,76 ****
  #define FILE1	(FILES | NOSPC)	/* 1 file allowed, defaults to current file */
  
  /* values for cmd_addr_type */
! #define ADDR_LINES		0
! #define ADDR_WINDOWS		1
! #define ADDR_ARGUMENTS		2
! #define ADDR_LOADED_BUFFERS	3
! #define ADDR_BUFFERS		4
! #define ADDR_TABS		5
! #define ADDR_TABS_RELATIVE	6   /* Tab page that only relative */
! #define ADDR_QUICKFIX		7
! #define ADDR_OTHER		99
  
  #ifndef DO_DECLARE_EXCMD
  typedef struct exarg exarg_T;
--- 62,76 ----
  #define FILE1	(FILES | NOSPC)	/* 1 file allowed, defaults to current file */
  
  /* values for cmd_addr_type */
! #define ADDR_LINES		0   // buffer line numbers
! #define ADDR_WINDOWS		1   // window number
! #define ADDR_ARGUMENTS		2   // argument number
! #define ADDR_LOADED_BUFFERS	3   // buffer number of loaded buffer
! #define ADDR_BUFFERS		4   // buffer number
! #define ADDR_TABS		5   // tab page number
! #define ADDR_TABS_RELATIVE	6   // Tab page that only relative
! #define ADDR_QUICKFIX		7   // quickfix list entry number
! #define ADDR_OTHER		99  // something else
  
  #ifndef DO_DECLARE_EXCMD
  typedef struct exarg exarg_T;
***************
*** 1260,1267 ****
  			EDITCMD|TRLBAR,
  			ADDR_LINES),
  EX(CMD_scriptnames,	"scriptnames",	ex_scriptnames,
! 			TRLBAR|CMDWIN,
! 			ADDR_LINES),
  EX(CMD_scriptencoding,	"scriptencoding", ex_scriptencoding,
  			WORD1|TRLBAR|CMDWIN,
  			ADDR_LINES),
--- 1260,1267 ----
  			EDITCMD|TRLBAR,
  			ADDR_LINES),
  EX(CMD_scriptnames,	"scriptnames",	ex_scriptnames,
! 			BANG|RANGE|NOTADR|COUNT|TRLBAR|CMDWIN,
! 			ADDR_OTHER),
  EX(CMD_scriptencoding,	"scriptencoding", ex_scriptencoding,
  			WORD1|TRLBAR|CMDWIN,
  			ADDR_LINES),
*** ../vim-8.1.0552/src/ex_cmds2.c	2018-11-10 17:33:23.087518814 +0100
--- src/ex_cmds2.c	2018-11-30 22:21:44.041191333 +0100
***************
*** 4690,4699 ****
   * ":scriptnames"
   */
      void
! ex_scriptnames(exarg_T *eap UNUSED)
  {
      int i;
  
      for (i = 1; i <= script_items.ga_len && !got_int; ++i)
  	if (SCRIPT_ITEM(i).sn_name != NULL)
  	{
--- 4690,4712 ----
   * ":scriptnames"
   */
      void
! ex_scriptnames(exarg_T *eap)
  {
      int i;
  
+     if (eap->addr_count > 0)
+     {
+ 	// :script {scriptId}: edit the script
+ 	if (eap->line2 < 1 || eap->line2 > script_items.ga_len)
+ 	    EMSG(_(e_invarg));
+ 	else
+ 	{
+ 	    eap->arg = SCRIPT_ITEM(eap->line2).sn_name;
+ 	    do_exedit(eap, NULL);
+ 	}
+ 	return;
+     }
+ 
      for (i = 1; i <= script_items.ga_len && !got_int; ++i)
  	if (SCRIPT_ITEM(i).sn_name != NULL)
  	{
*** ../vim-8.1.0552/src/testdir/test_scriptnames.vim	2018-11-30 22:36:54.859349269 +0100
--- src/testdir/test_scriptnames.vim	2018-11-30 22:39:33.306420278 +0100
***************
*** 0 ****
--- 1,26 ----
+ " Test for :scriptnames
+ 
+ func Test_scriptnames()
+   call writefile(['let did_load_script = 123'], 'Xscripting')
+   source Xscripting
+   call assert_equal(123, g:did_load_script)
+ 
+   let scripts = split(execute('scriptnames'), "\n")
+   let last = scripts[-1]
+   call assert_match('\<Xscripting\>', last)
+   let lastnr = substitute(last, '\D*\(\d\+\):.*', '\1', '')
+   exe 'script ' . lastnr
+   call assert_equal('Xscripting', expand('%:t'))
+ 
+   call assert_fails('script ' . (lastnr + 1), 'E474:')
+   call assert_fails('script 0', 'E939:')
+ 
+   new
+   call setline(1, 'nothing')
+   call assert_fails('script ' . lastnr, 'E37:')
+   exe 'script! ' . lastnr
+   call assert_equal('Xscripting', expand('%:t'))
+ 
+   bwipe
+   call delete('Xscripting')
+ endfunc
*** ../vim-8.1.0552/src/Make_all.mak	2018-11-10 18:54:40.656592081 +0100
--- src/Make_all.mak	2018-11-30 22:30:44.813583693 +0100
***************
*** 153,158 ****
--- 153,159 ----
  	test_reltime \
  	test_retab \
  	test_ruby \
+ 	test_scriptnames \
  	test_scroll_opt \
  	test_scrollbind \
  	test_search \
*** ../vim-8.1.0552/src/testdir/Make_all.mak	2018-06-30 21:50:16.852674935 +0200
--- src/testdir/Make_all.mak	2018-11-30 22:31:08.813435000 +0100
***************
*** 158,163 ****
--- 158,164 ----
  	    test_registers.res \
  	    test_retab.res \
  	    test_ruby.res \
+ 	    test_scriptnames.res \
  	    test_scrollbind.res \
  	    test_search.res \
  	    test_shortpathname.res \
*** ../vim-8.1.0552/runtime/doc/repeat.txt	2018-09-11 22:36:48.129548374 +0200
--- runtime/doc/repeat.txt	2018-11-30 22:33:59.476394395 +0100
***************
*** 334,339 ****
--- 334,342 ----
  			{not in Vi} {not available when compiled without the
  			|+eval| feature}
  
+ :scr[iptnames][!] {scriptId}			*:script*
+ 			Edit script {scriptId}.  Suggested name is ":script".
+ 
  						*:fini* *:finish* *E168*
  :fini[sh]		Stop sourcing a script.  Can only be used in a Vim
  			script file.  This is a quick way to skip the rest of
*** ../vim-8.1.0552/src/version.c	2018-11-30 21:57:50.723861874 +0100
--- src/version.c	2018-11-30 22:33:29.900572835 +0100
***************
*** 794,795 ****
--- 794,797 ----
  {   /* Add new patch number below this line */
+ /**/
+     553,
  /**/

-- 
   Another bucket of what can only be described as human ordure hits ARTHUR.
ARTHUR: ... Right!  (to the KNIGHTS) That settles it!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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    ///