mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	API/nvim_command_output: handle :echon capture (#8265)
ref https://github.com/neovim/python-client/pull/290
This commit is contained in:
		| @@ -239,15 +239,17 @@ String nvim_command_output(String command, Error *err) | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (capture_local.ga_len > 1) { |   if (capture_local.ga_len > 1) { | ||||||
|     // redir always(?) prepends a newline; remove it. |     String s = (String){ | ||||||
|     char *s = capture_local.ga_data; |       .data = capture_local.ga_data, | ||||||
|     assert(s[0] == '\n'); |       .size = (size_t)capture_local.ga_len, | ||||||
|     memmove(s, s + 1, (size_t)capture_local.ga_len); |  | ||||||
|     s[capture_local.ga_len - 1] = '\0'; |  | ||||||
|     return (String) {  // Caller will free the memory. |  | ||||||
|       .data = s, |  | ||||||
|       .size = (size_t)(capture_local.ga_len - 1), |  | ||||||
|     }; |     }; | ||||||
|  |     // redir usually (except :echon) prepends a newline. | ||||||
|  |     if (s.data[0] == '\n') { | ||||||
|  |       memmove(s.data, s.data + 1, s.size); | ||||||
|  |       s.data[s.size - 1] = '\0'; | ||||||
|  |       s.size = s.size - 1; | ||||||
|  |     } | ||||||
|  |     return s;  // Caller will free the memory. | ||||||
|   } |   } | ||||||
|  |  | ||||||
| theend: | theend: | ||||||
|   | |||||||
| @@ -73,6 +73,8 @@ describe('api', function() | |||||||
|     it('captures command output', function() |     it('captures command output', function() | ||||||
|       eq('this is\nspinal tap', |       eq('this is\nspinal tap', | ||||||
|          nvim('command_output', [[echo "this is\nspinal tap"]])) |          nvim('command_output', [[echo "this is\nspinal tap"]])) | ||||||
|  |       eq('no line ending!', | ||||||
|  |          nvim('command_output', [[echon "no line ending!"]])) | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it('captures empty command output', function() |     it('captures empty command output', function() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Justin M. Keyes
					Justin M. Keyes