|
5 | 5 |
|
6 | 6 | import * as dom from 'vs/base/browser/dom'; |
7 | 7 | import { Delayer } from 'vs/base/common/async'; |
8 | | -import { fromNow } from 'vs/base/common/date'; |
| 8 | +import { fromNow, getDurationString } from 'vs/base/common/date'; |
9 | 9 | import { MarkdownString } from 'vs/base/common/htmlContent'; |
10 | 10 | import { combinedDisposable, Disposable, IDisposable } from 'vs/base/common/lifecycle'; |
11 | 11 | import { localize } from 'vs/nls'; |
@@ -71,14 +71,29 @@ export class TerminalDecorationHoverManager extends Disposable { |
71 | 71 | } else { |
72 | 72 | return; |
73 | 73 | } |
74 | | - } else if (command.exitCode) { |
75 | | - if (command.exitCode === -1) { |
76 | | - hoverContent += localize('terminalPromptCommandFailed', 'Command executed {0} for {1} ms and failed', fromNow(command.timestamp, true), command.duration); |
| 74 | + } else { |
| 75 | + if (command.duration) { |
| 76 | + const durationText = getDurationString(command.duration); |
| 77 | + if (command.exitCode) { |
| 78 | + if (command.exitCode === -1) { |
| 79 | + hoverContent += localize('terminalPromptCommandFailed.duration', 'Command executed {0}, took {1} and failed', fromNow(command.timestamp, true), durationText); |
| 80 | + } else { |
| 81 | + hoverContent += localize('terminalPromptCommandFailedWithExitCode.duration', 'Command executed {0}, took {1} and failed (Exit Code {2})', fromNow(command.timestamp, true), durationText, command.exitCode); |
| 82 | + } |
| 83 | + } else { |
| 84 | + hoverContent += localize('terminalPromptCommandSuccess.duration', 'Command executed {0} and took {1}', fromNow(command.timestamp, true), durationText); |
| 85 | + } |
77 | 86 | } else { |
78 | | - hoverContent += localize('terminalPromptCommandFailedWithExitCode', 'Command executed {0} for {2} ms and failed (Exit Code {1})', fromNow(command.timestamp, true), command.exitCode, command.duration); |
| 87 | + if (command.exitCode) { |
| 88 | + if (command.exitCode === -1) { |
| 89 | + hoverContent += localize('terminalPromptCommandFailed', 'Command executed {0} and failed', fromNow(command.timestamp, true)); |
| 90 | + } else { |
| 91 | + hoverContent += localize('terminalPromptCommandFailedWithExitCode', 'Command executed {0} and failed (Exit Code {1})', fromNow(command.timestamp, true), command.exitCode); |
| 92 | + } |
| 93 | + } else { |
| 94 | + hoverContent += localize('terminalPromptCommandSuccess', 'Command executed {0}', fromNow(command.timestamp, true)); |
| 95 | + } |
79 | 96 | } |
80 | | - } else { |
81 | | - hoverContent += localize('terminalPromptCommandSuccess', 'Command executed {0} for {1} ms', fromNow(command.timestamp, true), command.duration); |
82 | 97 | } |
83 | 98 | this._hoverService.showHover({ content: new MarkdownString(hoverContent), target: element }); |
84 | 99 | }); |
|
0 commit comments