From 4813ad48cd12a03ca50c01ac1b20518bf4df57f2 Mon Sep 17 00:00:00 2001 From: erw7 Date: Mon, 20 May 2019 11:57:45 +0900 Subject: vim-patch:8.1.0027: difficult to make a plugin that feeds a line to a job Problem: Difficult to make a plugin that feeds a line to a job. Solution: Add the nitial code for the "prompt" buftype. https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787 --- test/functional/legacy/prompt_buffer_spec.lua | 84 +++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 test/functional/legacy/prompt_buffer_spec.lua (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua new file mode 100644 index 0000000000..749e65a985 --- /dev/null +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -0,0 +1,84 @@ +local helpers = require('test.functional.helpers')(after_each) +local Screen = require('test.functional.ui.screen') +local feed= helpers.feed +local source = helpers.source +local clear = helpers.clear +local feed_command = helpers.feed_command + +describe('prompt buffer', function() + local screen + + before_each(function() + clear() + screen = Screen.new(25, 10) + screen:attach() + source([[ + func TextEntered(text) + if a:text == "exit" + stopinsert + close + else + call append(line("$") - 1, 'Command: "' . a:text . '"') + set nomodfied + call timer_start(20, {id -> TimerFunc(a:text)}) + endif + endfunc + + func TimerFunc(text) + call append(line("$") - 1, 'Result: "' . a:text .'"') + endfunc + ]]) + end) + + after_each(function() + screen:detach() + end) + + it('works', function() + feed_command("set noshowmode | set laststatus=0") + feed_command("call setline(1, 'other buffer')") + feed_command("new") + feed_command("set buftype=prompt") + feed_command("call prompt_setcallback(bufnr(''), function('TextEntered'))") + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + [Scratch] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + feed_command("startinsert") + feed("hello\n") + screen:expect([[ + % hello | + Command: "hello" | + Result: "hello" | + % ^ | + [Scratch] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + feed("exit\n") + screen:expect([[ + ^other buffer | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + | + ]]) + end) + +end) -- cgit From 3ca0343fb99b7f7412fca73be6f94df252b6f0a3 Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 23 May 2019 01:47:56 +0900 Subject: vim-patch:8.1.0032: BS in prompt buffer starts new line 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. https://github.com/vim/vim/commit/6b810d92a9cd9378ab46ea0db07079cb789f9faa --- test/functional/legacy/prompt_buffer_spec.lua | 80 +++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 6 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index 749e65a985..d494bb5a81 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -28,6 +28,11 @@ describe('prompt buffer', function() call append(line("$") - 1, 'Result: "' . a:text .'"') endfunc ]]) + feed_command("set noshowmode | set laststatus=0") + feed_command("call setline(1, 'other buffer')") + feed_command("new") + feed_command("set buftype=prompt") + feed_command("call prompt_setcallback(bufnr(''), function('TextEntered'))") end) after_each(function() @@ -35,11 +40,6 @@ describe('prompt buffer', function() end) it('works', function() - feed_command("set noshowmode | set laststatus=0") - feed_command("call setline(1, 'other buffer')") - feed_command("new") - feed_command("set buftype=prompt") - feed_command("call prompt_setcallback(bufnr(''), function('TextEntered'))") screen:expect([[ ^ | ~ | @@ -52,7 +52,7 @@ describe('prompt buffer', function() ~ | | ]]) - feed_command("startinsert") + feed("i") feed("hello\n") screen:expect([[ % hello | @@ -81,4 +81,72 @@ describe('prompt buffer', function() ]]) end) + it('editing', function() + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + [Scratch] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + feed("i") + feed("hello") + screen:expect([[ + % hel^ | + ~ | + ~ | + ~ | + [Scratch] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + feed("-") + screen:expect([[ + % -^hel | + ~ | + ~ | + ~ | + [Scratch] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + feed("x") + screen:expect([[ + % -helx^ | + ~ | + ~ | + ~ | + [Scratch] | + other buffer | + ~ | + ~ | + ~ | + | + ]]) + feed("exit\n") + screen:expect([[ + ^other buffer | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + ~ | + | + ]]) + end) + end) -- cgit From 783aecd501de2719f3059252e8444ef00c7c3d4a Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 23 May 2019 05:15:04 +0900 Subject: vim-patch:8.1.0036: not restoring Insert mode if leaving prompt buffer with mouse Problem: Not restoring Insert mode if leaving a prompt buffer by using a mouse click. Solution: Set b_prompt_insert appropriately. Also correct cursor position when moving cursor to last line. https://github.com/vim/vim/commit/891e1fd894720d0b99a9daefa41e8181844f819a --- test/functional/legacy/prompt_buffer_spec.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index d494bb5a81..d5b315a0c7 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -45,7 +45,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Scratch] | + [Prompt] | other buffer | ~ | ~ | @@ -59,7 +59,7 @@ describe('prompt buffer', function() Command: "hello" | Result: "hello" | % ^ | - [Scratch] | + [Prompt] | other buffer | ~ | ~ | @@ -87,7 +87,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Scratch] | + [Prompt] | other buffer | ~ | ~ | @@ -101,7 +101,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Scratch] | + [Prompt] | other buffer | ~ | ~ | @@ -114,7 +114,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Scratch] | + [Prompt] | other buffer | ~ | ~ | @@ -127,7 +127,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Scratch] | + [Prompt] | other buffer | ~ | ~ | -- cgit From 3557757a3c410bb5c6a9066b342b4f42b75ec5ed Mon Sep 17 00:00:00 2001 From: erw7 Date: Sat, 25 May 2019 13:15:01 +0900 Subject: vim-patch:8.1.0092: prompt buffer test fails Problem: Prompt buffer test fails. Solution: Set 'nomodified' before closing the window. (Ozaki Kiichi, closes vim/vim#3051 https://github.com/vim/vim/commit/71ef1ba5e996f34d3e0acbe1d89c4c6bfa5e98ba --- test/functional/legacy/prompt_buffer_spec.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'test/functional/legacy/prompt_buffer_spec.lua') diff --git a/test/functional/legacy/prompt_buffer_spec.lua b/test/functional/legacy/prompt_buffer_spec.lua index d5b315a0c7..513be807be 100644 --- a/test/functional/legacy/prompt_buffer_spec.lua +++ b/test/functional/legacy/prompt_buffer_spec.lua @@ -15,6 +15,7 @@ describe('prompt buffer', function() source([[ func TextEntered(text) if a:text == "exit" + set nomodified stopinsert close else @@ -59,7 +60,7 @@ describe('prompt buffer', function() Command: "hello" | Result: "hello" | % ^ | - [Prompt] | + [Prompt] [+] | other buffer | ~ | ~ | @@ -101,7 +102,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Prompt] | + [Prompt] [+] | other buffer | ~ | ~ | @@ -114,7 +115,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Prompt] | + [Prompt] [+] | other buffer | ~ | ~ | @@ -127,7 +128,7 @@ describe('prompt buffer', function() ~ | ~ | ~ | - [Prompt] | + [Prompt] [+] | other buffer | ~ | ~ | -- cgit