File tree Expand file tree Collapse file tree 1 file changed +14
-15
lines changed
Expand file tree Collapse file tree 1 file changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -93,11 +93,6 @@ func (w *ttyWriter) Start(ctx context.Context, operation string) {
9393 w .ticker .Stop ()
9494 return
9595 case <- w .done :
96- w .print ()
97- w .mtx .Lock ()
98- w .ticker .Stop ()
99- w .operation = ""
100- w .mtx .Unlock ()
10196 return
10297 case <- w .ticker .C :
10398 w .print ()
@@ -107,6 +102,11 @@ func (w *ttyWriter) Start(ctx context.Context, operation string) {
107102}
108103
109104func (w * ttyWriter ) Done (operation string , success bool ) {
105+ w .print ()
106+ w .mtx .Lock ()
107+ defer w .mtx .Unlock ()
108+ w .ticker .Stop ()
109+ w .operation = ""
110110 w .done <- true
111111}
112112
@@ -213,18 +213,17 @@ func (w *ttyWriter) print() {
213213 return
214214 }
215215 terminalWidth := goterm .Width ()
216- b := aec .EmptyBuilder
217- for i := 0 ; i <= w .numLines ; i ++ {
218- b = b .Up (1 )
219- }
216+ up := w .numLines + 1
220217 if ! w .repeated {
221- b = b .Down (1 )
218+ up --
219+ w .repeated = true
222220 }
223- w .repeated = true
224- _ , _ = fmt .Fprint (w .out , b .Column (0 ).ANSI )
225-
226- // Hide the cursor while we are printing
227- _ , _ = fmt .Fprint (w .out , aec .Hide )
221+ b := aec .NewBuilder (
222+ aec .Hide , // Hide the cursor while we are printing
223+ aec .Up (uint (up )),
224+ aec .Column (0 ),
225+ )
226+ _ , _ = fmt .Fprint (w .out , b .ANSI )
228227 defer func () {
229228 _ , _ = fmt .Fprint (w .out , aec .Show )
230229 }()
You can’t perform that action at this time.
0 commit comments