@@ -12,53 +12,55 @@ import { ITerminalAutoActivation } from './types';
12
12
13
13
@injectable ( )
14
14
export class TerminalAutoActivation implements ITerminalAutoActivation {
15
- private handler ?: IDisposable ;
15
+ private handler ?: IDisposable ;
16
16
17
- private readonly terminalsNotToAutoActivate = new WeakSet < Terminal > ( ) ;
17
+ private readonly terminalsNotToAutoActivate = new WeakSet < Terminal > ( ) ;
18
18
19
- constructor (
20
- @inject ( ITerminalManager )
21
- private readonly terminalManager : ITerminalManager ,
22
- @inject ( IDisposableRegistry ) disposableRegistry : IDisposableRegistry ,
23
- @inject ( ITerminalActivator ) private readonly activator : ITerminalActivator ,
24
- @inject ( IActiveResourceService )
25
- private readonly activeResourceService : IActiveResourceService
26
- ) {
27
- disposableRegistry . push ( this ) ;
28
- }
29
-
30
- public dispose ( ) : void {
31
- if ( this . handler ) {
32
- this . handler . dispose ( ) ;
33
- this . handler = undefined ;
19
+ constructor (
20
+ @inject ( ITerminalManager )
21
+ private readonly terminalManager : ITerminalManager ,
22
+ @inject ( IDisposableRegistry ) disposableRegistry : IDisposableRegistry ,
23
+ @inject ( ITerminalActivator ) private readonly activator : ITerminalActivator ,
24
+ @inject ( IActiveResourceService )
25
+ private readonly activeResourceService : IActiveResourceService ,
26
+ ) {
27
+ disposableRegistry . push ( this ) ;
34
28
}
35
- }
36
29
37
- public register ( ) : void {
38
- if ( this . handler ) {
39
- return ;
30
+ public dispose ( ) : void {
31
+ if ( this . handler ) {
32
+ this . handler . dispose ( ) ;
33
+ this . handler = undefined ;
34
+ }
40
35
}
41
- this . handler = this . terminalManager . onDidOpenTerminal ( this . activateTerminal , this ) ;
42
- }
43
-
44
- public disableAutoActivation ( terminal : Terminal ) : void {
45
- this . terminalsNotToAutoActivate . add ( terminal ) ;
46
- }
47
36
48
- private async activateTerminal ( terminal : Terminal ) : Promise < void > {
49
- if ( this . terminalsNotToAutoActivate . has ( terminal ) ) {
50
- return ;
37
+ public register ( ) : void {
38
+ if ( this . handler ) {
39
+ return ;
40
+ }
41
+ this . handler = this . terminalManager . onDidOpenTerminal ( this . activateTerminal , this ) ;
51
42
}
52
- if ( 'hideFromUser' in terminal . creationOptions && terminal . creationOptions . hideFromUser ) {
53
- return ;
43
+
44
+ public disableAutoActivation ( terminal : Terminal ) : void {
45
+ this . terminalsNotToAutoActivate . add ( terminal ) ;
54
46
}
55
47
56
- const cwd =
57
- 'cwd' in terminal . creationOptions ? terminal . creationOptions . cwd : this . activeResourceService . getActiveResource ( ) ;
58
- const resource = typeof cwd === 'string' ? Uri . file ( cwd ) : cwd ;
48
+ private async activateTerminal ( terminal : Terminal ) : Promise < void > {
49
+ if ( this . terminalsNotToAutoActivate . has ( terminal ) ) {
50
+ return ;
51
+ }
52
+ if ( 'hideFromUser' in terminal . creationOptions && terminal . creationOptions . hideFromUser ) {
53
+ return ;
54
+ }
59
55
60
- await this . activator . activateEnvironmentInTerminal ( terminal , {
61
- resource,
62
- } ) ;
63
- }
56
+ const cwd =
57
+ 'cwd' in terminal . creationOptions
58
+ ? terminal . creationOptions . cwd
59
+ : this . activeResourceService . getActiveResource ( ) ;
60
+ const resource = typeof cwd === 'string' ? Uri . file ( cwd ) : cwd ;
61
+
62
+ await this . activator . activateEnvironmentInTerminal ( terminal , {
63
+ resource,
64
+ } ) ;
65
+ }
64
66
}
0 commit comments