summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0032
blob: f5ea02843e7b8ae8b1f1d1d676645142ce073d31 (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
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0032
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.0032
Problem:    BS in prompt buffer starts new line.
Solution:   Do not allows BS over the prompt.  Make term_sendkeys() handle
            special keys. Add a test.
Files:	    src/option.c, src/terminal.c, src/testdir/test_prompt_buffer.vim


*** ../vim-8.1.0031/src/option.c	2018-06-03 14:42:17.848505102 +0200
--- src/option.c	2018-06-04 16:51:10.811551036 +0200
***************
*** 12439,12444 ****
--- 12439,12448 ----
  can_bs(
      int		what)	    /* BS_INDENT, BS_EOL or BS_START */
  {
+ #ifdef FEAT_JOB_CHANNEL
+     if (what == BS_START && bt_prompt(curbuf))
+ 	return FALSE;
+ #endif
      switch (*p_bs)
      {
  	case '2':	return TRUE;
*** ../vim-8.1.0031/src/terminal.c	2018-05-21 22:50:22.514568516 +0200
--- src/terminal.c	2018-06-04 16:51:10.815551032 +0200
***************
*** 5094,5101 ****
  
      while (*msg != NUL)
      {
! 	send_keys_to_term(term, PTR2CHAR(msg), FALSE);
! 	msg += MB_CPTR2LEN(msg);
      }
  }
  
--- 5094,5112 ----
  
      while (*msg != NUL)
      {
! 	int c;
! 
! 	if (*msg == K_SPECIAL && msg[1] != NUL && msg[2] != NUL)
! 	{
! 	    c = TO_SPECIAL(msg[1], msg[2]);
! 	    msg += 3;
! 	}
! 	else
! 	{
! 	    c = PTR2CHAR(msg);
! 	    msg += MB_CPTR2LEN(msg);
! 	}
! 	send_keys_to_term(term, c, FALSE);
      }
  }
  
*** ../vim-8.1.0031/src/testdir/test_prompt_buffer.vim	2018-06-03 17:10:36.274226639 +0200
--- src/testdir/test_prompt_buffer.vim	2018-06-04 17:13:41.298470827 +0200
***************
*** 7,22 ****
  source shared.vim
  source screendump.vim
  
! func Test_prompt_basic()
    " We need to use a terminal window to be able to feed keys without leaving
    " Insert mode.
    if !has('terminal')
!     return
    endif
    if has('win32')
!     " TODO: make this work on MS-Windows
!     return
    endif
    call writefile([
  	\ 'func TextEntered(text)',
  	\ '  if a:text == "exit"',
--- 7,26 ----
  source shared.vim
  source screendump.vim
  
! func CanTestPromptBuffer()
    " We need to use a terminal window to be able to feed keys without leaving
    " Insert mode.
    if !has('terminal')
!     return 0
    endif
    if has('win32')
!     " TODO: make the tests work on MS-Windows
!     return 0
    endif
+   return 1
+ endfunc
+ 
+ func WriteScript(name)
    call writefile([
  	\ 'func TextEntered(text)',
  	\ '  if a:text == "exit"',
***************
*** 44,51 ****
  	\ 'set buftype=prompt',
  	\ 'call prompt_setcallback(bufnr(""), function("TextEntered"))',
  	\ 'startinsert',
! 	\ ], 'Xpromptscript')
!   let buf = RunVimInTerminal('-S Xpromptscript', {})
    call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))})
  
    call term_sendkeys(buf, "hello\<CR>")
--- 48,64 ----
  	\ 'set buftype=prompt',
  	\ 'call prompt_setcallback(bufnr(""), function("TextEntered"))',
  	\ 'startinsert',
! 	\ ], a:name)
! endfunc
! 
! func Test_prompt_basic()
!   if !CanTestPromptBuffer()
!     return
!   endif
!   let scriptName = 'XpromptscriptBasic'
!   call WriteScript(scriptName)
! 
!   let buf = RunVimInTerminal('-S ' . scriptName, {})
    call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))})
  
    call term_sendkeys(buf, "hello\<CR>")
***************
*** 57,61 ****
    call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})
  
    call StopVimInTerminal(buf)
!   call delete('Xpromptscript')
  endfunc
--- 70,103 ----
    call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})
  
    call StopVimInTerminal(buf)
!   call delete(scriptName)
! endfunc
! 
! func Test_prompt_editing()
!   if !CanTestPromptBuffer()
!     return
!   endif
!   let scriptName = 'XpromptscriptEditing'
!   call WriteScript(scriptName)
! 
!   let buf = RunVimInTerminal('-S ' . scriptName, {})
!   call WaitForAssert({-> assert_equal('%', term_getline(buf, 1))})
! 
!   let bs = "\<BS>"
!   call term_sendkeys(buf, "hello" . bs . bs)
!   call WaitForAssert({-> assert_equal('% hel', term_getline(buf, 1))})
! 
!   let left = "\<Left>"
!   call term_sendkeys(buf, left . left . left . bs . '-')
!   call WaitForAssert({-> assert_equal('% -hel', term_getline(buf, 1))})
! 
!   let end = "\<End>"
!   call term_sendkeys(buf, end . "x")
!   call WaitForAssert({-> assert_equal('% -helx', term_getline(buf, 1))})
! 
!   call term_sendkeys(buf, "\<C-U>exit\<CR>")
!   call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))})
! 
!   call StopVimInTerminal(buf)
!   call delete(scriptName)
  endfunc
*** ../vim-8.1.0031/src/version.c	2018-06-03 18:21:57.809890160 +0200
--- src/version.c	2018-06-04 17:05:58.770829349 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     32,
  /**/

-- 
I have a drinking problem -- I can't afford it.

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