mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Merge #9297 from justinmk/confirm-dialog
This commit is contained in:
		| @@ -37,6 +37,7 @@ Functions ~ | |||||||
| *file_readable()*	Obsolete name for |filereadable()|. | *file_readable()*	Obsolete name for |filereadable()|. | ||||||
| *highlight_exists()*	Obsolete name for |hlexists()|. | *highlight_exists()*	Obsolete name for |hlexists()|. | ||||||
| *highlightID()*		Obsolete name for |hlID()|. | *highlightID()*		Obsolete name for |hlID()|. | ||||||
|  | *inputdialog()*		Use |input()| instead. | ||||||
| *jobclose()*		Obsolete name for |chanclose()| | *jobclose()*		Obsolete name for |chanclose()| | ||||||
| *jobsend()*		Obsolete name for |chansend()| | *jobsend()*		Obsolete name for |chansend()| | ||||||
| *last_buffer_nr()*	Obsolete name for bufnr("$"). | *last_buffer_nr()*	Obsolete name for bufnr("$"). | ||||||
|   | |||||||
| @@ -2137,8 +2137,6 @@ index({list}, {expr} [, {start} [, {ic}]]) | |||||||
| 				Number	index in {list} where {expr} appears | 				Number	index in {list} where {expr} appears | ||||||
| input({prompt} [, {text} [, {completion}]]) | input({prompt} [, {text} [, {completion}]]) | ||||||
| 				String	get input from the user | 				String	get input from the user | ||||||
| inputdialog({prompt} [, {text} [, {completion}]]) |  | ||||||
| 				String  like input() but in a GUI dialog |  | ||||||
| inputlist({textlist})		Number	let the user pick from a choice list | inputlist({textlist})		Number	let the user pick from a choice list | ||||||
| inputrestore()			Number	restore typeahead | inputrestore()			Number	restore typeahead | ||||||
| inputsave()			Number	save and clear typeahead | inputsave()			Number	save and clear typeahead | ||||||
| @@ -4915,20 +4913,6 @@ input({opts}) | |||||||
| 			:  call inputrestore() | 			:  call inputrestore() | ||||||
| 			:endfunction | 			:endfunction | ||||||
|  |  | ||||||
| inputdialog({prompt} [, {text} [, {cancelreturn}]])		*inputdialog()* |  | ||||||
| inputdialog({opts}) |  | ||||||
| 		Like |input()|, but when the GUI is running and text dialogs |  | ||||||
| 		are supported, a dialog window pops up to input the text. |  | ||||||
| 		Example: > |  | ||||||
| 		   :let n = inputdialog("value for shiftwidth", shiftwidth()) |  | ||||||
| 		   :if n != "" |  | ||||||
| 		   :  let &sw = n |  | ||||||
| 		   :endif |  | ||||||
| <		When the dialog is cancelled {cancelreturn} is returned.  When |  | ||||||
| 		omitted an empty string is returned. |  | ||||||
| 		Hitting <Enter> works like pressing the OK button.  Hitting |  | ||||||
| 		<Esc> works like pressing the Cancel button. |  | ||||||
|  |  | ||||||
| inputlist({textlist})					*inputlist()* | inputlist({textlist})					*inputlist()* | ||||||
| 		{textlist} must be a |List| of strings.  This |List| is | 		{textlist} must be a |List| of strings.  This |List| is | ||||||
| 		displayed, one string per line.  The user will be prompted to | 		displayed, one string per line.  The user will be prompted to | ||||||
|   | |||||||
| @@ -517,14 +517,9 @@ m  *+xim*		X input method |xim| | |||||||
| 			    :silent! /^begin | 			    :silent! /^begin | ||||||
| 			    :if v:errmsg != "" | 			    :if v:errmsg != "" | ||||||
| 			    : ... pattern was not found | 			    : ... pattern was not found | ||||||
| <			":silent" will also avoid the hit-enter prompt.  When | <			":silent" also skips the hit-enter prompt. | ||||||
| 			using this for an external command, this may cause the | 			Dialogs that prompt for user input (|confirm()|, | ||||||
| 			screen to be messed up.  Use |CTRL-L| to clean it up | 			'swapfile', …) are never silent. | ||||||
| 			then. |  | ||||||
| 			":silent menu ..." defines a menu that will not echo a |  | ||||||
| 			Command-line command.  The command will still produce |  | ||||||
| 			messages though.  Use ":silent" in the command itself |  | ||||||
| 			to avoid that: ":silent menu .... :silent command". |  | ||||||
|  |  | ||||||
| 						*:uns* *:unsilent* | 						*:uns* *:unsilent* | ||||||
| :uns[ilent] {command}	Execute {command} not silently.  Only makes a | :uns[ilent] {command}	Execute {command} not silently.  Only makes a | ||||||
|   | |||||||
| @@ -2825,7 +2825,6 @@ do_dialog ( | |||||||
|                                Ex command */ |                                Ex command */ | ||||||
| ) | ) | ||||||
| { | { | ||||||
|   int oldState; |  | ||||||
|   int retval = 0; |   int retval = 0; | ||||||
|   char_u      *hotkeys; |   char_u      *hotkeys; | ||||||
|   int c; |   int c; | ||||||
| @@ -2838,7 +2837,10 @@ do_dialog ( | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|   oldState = State; |   int save_msg_silent = msg_silent; | ||||||
|  |   int oldState = State; | ||||||
|  |  | ||||||
|  |   msg_silent = 0;  // If dialog prompts for input, user needs to see it! #8788 | ||||||
|   State = CONFIRM; |   State = CONFIRM; | ||||||
|   setmouse(); |   setmouse(); | ||||||
|  |  | ||||||
| @@ -2891,6 +2893,7 @@ do_dialog ( | |||||||
|  |  | ||||||
|   xfree(hotkeys); |   xfree(hotkeys); | ||||||
|  |  | ||||||
|  |   msg_silent = save_msg_silent; | ||||||
|   State = oldState; |   State = oldState; | ||||||
|   setmouse(); |   setmouse(); | ||||||
|   --no_wait_return; |   --no_wait_return; | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ local clear = helpers.clear | |||||||
| local source = helpers.source | local source = helpers.source | ||||||
| local command = helpers.command | local command = helpers.command | ||||||
| local exc_exec = helpers.exc_exec | local exc_exec = helpers.exc_exec | ||||||
|  | local nvim_async = helpers.nvim_async | ||||||
|  |  | ||||||
| local screen | local screen | ||||||
|  |  | ||||||
| @@ -59,6 +60,7 @@ before_each(function() | |||||||
|     RBP3={background=Screen.colors.Green}, |     RBP3={background=Screen.colors.Green}, | ||||||
|     RBP4={background=Screen.colors.Blue}, |     RBP4={background=Screen.colors.Blue}, | ||||||
|     SEP={bold = true, reverse = true}, |     SEP={bold = true, reverse = true}, | ||||||
|  |     CONFIRM={bold = true, foreground = Screen.colors.SeaGreen4}, | ||||||
|   }) |   }) | ||||||
| end) | end) | ||||||
|  |  | ||||||
| @@ -439,3 +441,43 @@ describe('inputdialog()', function() | |||||||
|     ]]) |     ]]) | ||||||
|   end) |   end) | ||||||
| end) | end) | ||||||
|  |  | ||||||
|  | describe('confirm()', function() | ||||||
|  |   it("shows dialog even if :silent #8788", function() | ||||||
|  |     command("autocmd BufNewFile * call confirm('test')") | ||||||
|  |  | ||||||
|  |     local function check_and_clear(edit_line) | ||||||
|  |       screen:expect([[ | ||||||
|  |                                  | | ||||||
|  |         {SEP:                         }| | ||||||
|  |         ]]..edit_line..[[ | ||||||
|  |         {CONFIRM:test}                     | | ||||||
|  |         {CONFIRM:[O]k: }^                   | | ||||||
|  |       ]]) | ||||||
|  |       feed('<cr>') | ||||||
|  |       command('redraw') | ||||||
|  |       command('bdelete!') | ||||||
|  |     end | ||||||
|  |  | ||||||
|  |     -- With shortmess-=F | ||||||
|  |     command('set shortmess-=F') | ||||||
|  |     feed(':edit foo<cr>') | ||||||
|  |     check_and_clear('"foo" [New File]         |\n') | ||||||
|  |  | ||||||
|  |     -- With shortmess+=F | ||||||
|  |     command('set shortmess+=F') | ||||||
|  |     feed(':edit foo<cr>') | ||||||
|  |     check_and_clear(':edit foo                |\n') | ||||||
|  |  | ||||||
|  |     -- With :silent | ||||||
|  |     feed(':silent edit foo<cr>') | ||||||
|  |     check_and_clear(':silent edit foo         |\n') | ||||||
|  |  | ||||||
|  |     -- With API (via eval/VimL) call and shortmess+=F | ||||||
|  |     feed(':call nvim_command("edit x")<cr>') | ||||||
|  |     check_and_clear(':call nvim_command("edit |\n') | ||||||
|  |  | ||||||
|  |     nvim_async('command', 'edit x') | ||||||
|  |     check_and_clear('                         |\n') | ||||||
|  |   end) | ||||||
|  | end) | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ local ok = helpers.ok | |||||||
| local rmdir = helpers.rmdir | local rmdir = helpers.rmdir | ||||||
| local set_session = helpers.set_session | local set_session = helpers.set_session | ||||||
| local spawn = helpers.spawn | local spawn = helpers.spawn | ||||||
|  | local nvim_async = helpers.nvim_async | ||||||
|  |  | ||||||
| describe(':recover', function() | describe(':recover', function() | ||||||
|   before_each(clear) |   before_each(clear) | ||||||
| @@ -150,5 +151,12 @@ describe('swapfile detection', function() | |||||||
|     feed('e')  -- Chose "Edit" at the swap dialog. |     feed('e')  -- Chose "Edit" at the swap dialog. | ||||||
|     feed('<c-c>') |     feed('<c-c>') | ||||||
|     screen2:expect(expected_no_dialog) |     screen2:expect(expected_no_dialog) | ||||||
|  |  | ||||||
|  |     -- With API call and shortmess+=F | ||||||
|  |     nvim_async('command', 'edit %') | ||||||
|  |     screen2:expect{any=[[Found a swap file by the name ".*]] | ||||||
|  |                        ..[[Xtest_swapdialog_dir[/\].*]]..testfile..[[%.swp"]]} | ||||||
|  |     feed('e')  -- Chose "Edit" at the swap dialog. | ||||||
|  |     feed('<c-c>') | ||||||
|   end) |   end) | ||||||
| end) | end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Justin M. Keyes
					Justin M. Keyes