Thread (4 messages) flat view 4 messages, 3 authors, 2017-12-07

Re: [PATCH v5 2/2] launch_editor(): indicate that Git waits for user input

From: Kaartic Sivaraam <hidden>
Date: 2017-12-07 17:40:52

Possibly related (same subject, not in this thread)

On Thursday 07 December 2017 10:00 PM, Junio C Hamano wrote:
+
+		if (print_waiting_for_editor) {
+			/*
+			 * A dumb terminal cannot erase the line later on. Add a
+			 * newline to separate the hint from subsequent output.
+			 *
+			 * In case the editor emits further cruft after what
+			 * we wrote above, separate it from our message with SP.
I guess this part of the comment could be improved a little. I currently 
interpret it as "See if the editor emits further cruft, print a space in 
that case". Though, it's not what we are doing. Something like the 
following, perhaps?

      In a non-dumb terminal, separate our message from further cruft
      that might be emitted by the editor with SP.


quoted hunk ↗ jump to hunk
+			 */
+			const char term = is_terminal_dumb() ? '\n' : ' ';
+
+			fprintf(stderr,
+				_("hint: Waiting for your editor to close the file...%c"),
+				term);
+			fflush(stderr);
+		}
  
  		p.argv = args;
  		p.env = env;
@@ -63,6 +80,13 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
  		if (ret)
  			return error("There was a problem with the editor '%s'.",
  					editor);
+
+		if (print_waiting_for_editor && !is_terminal_dumb())
+			/*
+			 * Go back to the beginning and erase the entire line to
+			 * avoid wasting the vertical space.
+			 */
+			fputs("\r\033[K", stderr);
  	}
  
  	if (!buffer)
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help