Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cli/azd/pkg/input/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,18 @@ func (c *AskerConsole) ShowPreviewer(ctx context.Context, options *ShowPreviewer
options = defaultShowPreviewerOptions()
}

c.previewer = NewProgressLog(options.MaxLineCount, options.Prefix, options.Title, c.currentIndent.Load()+currentMsg)
c.previewer = newProgressLogWithWidthFn(
options.MaxLineCount,
options.Prefix,
options.Title,
c.currentIndent.Load()+currentMsg,
func() int {
if c.consoleWidth == nil {
Comment thread
weikanglim marked this conversation as resolved.
return 0
}

return int(c.consoleWidth.Load())
})
Comment thread
weikanglim marked this conversation as resolved.
c.previewer.Start()
c.writer = c.previewer
return &consolePreviewerWriter{
Expand Down
9 changes: 7 additions & 2 deletions cli/azd/pkg/input/progress_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ type progressLog struct {
output []string
// The mutex is used to coordinate updating the header, stopping the component and printing logs.
outputMutex sync.Mutex
// This function is used to find out what's the terminal width. The log progress is disabled if this function
// returns a number <= 0.
// This function is used to find out what's the terminal width. The log progress is disabled, i.e. writes are no-opt,
Comment thread
weikanglim marked this conversation as resolved.
// if this function returns a number <= 0.
terminalWidthFn TerminalWidthFn
}

Expand Down Expand Up @@ -98,6 +98,11 @@ func (p *progressLog) Start() {
return
}

consoleLen := p.terminalWidthFn()
if consoleLen <= 0 {
return
}
Comment thread
weikanglim marked this conversation as resolved.

lineCount := p.lines
if lineCount == 0 {
lineCount = 1
Expand Down
Loading