@@ -32,7 +32,7 @@ import { Color } from 'vs/base/common/color';
32
32
import { ShellIntegrationAddon } from 'vs/platform/terminal/common/xterm/shellIntegrationAddon' ;
33
33
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
34
34
import { DecorationAddon } from 'vs/workbench/contrib/terminal/browser/xterm/decorationAddon' ;
35
- import { ITerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/capabilities' ;
35
+ import { ITerminalCapabilityStore , ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities' ;
36
36
import { Emitter } from 'vs/base/common/event' ;
37
37
38
38
// How long in milliseconds should an average frame take to render for a notification to appear
@@ -71,7 +71,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal {
71
71
private _lastFindResult : { resultIndex : number ; resultCount : number } | undefined ;
72
72
get findResult ( ) : { resultIndex : number ; resultCount : number } | undefined { return this . _lastFindResult ; }
73
73
74
- private readonly _onDidRequestRunCommand = new Emitter < string > ( ) ;
74
+ private readonly _onDidRequestRunCommand = new Emitter < { command : ITerminalCommand ; copyAsHtml ?: boolean } > ( ) ;
75
75
readonly onDidRequestRunCommand = this . _onDidRequestRunCommand . event ;
76
76
77
77
private readonly _onDidChangeFindResults = new Emitter < { resultIndex : number ; resultCount : number } | undefined > ( ) ;
@@ -175,17 +175,29 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal {
175
175
}
176
176
private _createDecorationAddon ( ) : void {
177
177
this . _decorationAddon = this . _instantiationService . createInstance ( DecorationAddon , this . _capabilities ) ;
178
- this . _decorationAddon . onDidRequestRunCommand ( command => this . _onDidRequestRunCommand . fire ( command ) ) ;
178
+ this . _decorationAddon . onDidRequestRunCommand ( e => this . _onDidRequestRunCommand . fire ( e ) ) ;
179
179
this . raw . loadAddon ( this . _decorationAddon ) ;
180
180
}
181
181
182
- async getSelectionAsHtml ( ) : Promise < string > {
182
+ async getSelectionAsHtml ( command ?: ITerminalCommand ) : Promise < string > {
183
183
if ( ! this . _serializeAddon ) {
184
184
const Addon = await this . _getSerializeAddonConstructor ( ) ;
185
185
this . _serializeAddon = new Addon ( ) ;
186
186
this . raw . loadAddon ( this . _serializeAddon ) ;
187
187
}
188
- return this . _serializeAddon . serializeAsHTML ( { onlySelection : true } ) ;
188
+ if ( command ) {
189
+ const length = command . getOutput ( ) ?. length ;
190
+ const row = command . marker ?. line ;
191
+ if ( ! length || ! row ) {
192
+ throw new Error ( `No row ${ row } or output length ${ length } for command ${ command } ` ) ;
193
+ }
194
+ await this . raw . select ( 0 , row + 1 , length - Math . floor ( length / this . raw . cols ) ) ;
195
+ }
196
+ const result = this . _serializeAddon . serializeAsHTML ( { onlySelection : true } ) ;
197
+ if ( command ) {
198
+ this . raw . clearSelection ( ) ;
199
+ }
200
+ return result ;
189
201
}
190
202
191
203
attachToElement ( container : HTMLElement ) : HTMLElement {
0 commit comments