This repository was archived by the owner on May 21, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ export abstract class ASTNode {
21
21
abstract get fullEnd ( ) : number ;
22
22
}
23
23
24
+ const isEndOfCommand = ( token : Scanner . Token ) => token instanceof Scanner . Semicolon || token instanceof Scanner . NewLine ;
25
+
24
26
abstract class LeafNode extends ASTNode {
25
27
constructor ( private token : Scanner . Token ) {
26
28
super ( ) ;
@@ -86,11 +88,14 @@ abstract class BranchNode extends ASTNode {
86
88
}
87
89
}
88
90
91
+ /**
92
+ * The whole command, the input string.
93
+ */
89
94
export class CompleteCommand extends BranchNode {
90
95
@memoizeAccessor
91
96
get children ( ) : ASTNode [ ] {
92
97
const lastChild = _ . last ( this . tokens ) ! ;
93
- const endsWithSeparator = lastChild instanceof Scanner . Semicolon ;
98
+ const endsWithSeparator = isEndOfCommand ( lastChild ) ;
94
99
95
100
if ( endsWithSeparator ) {
96
101
return [
@@ -117,7 +122,7 @@ export class CompleteCommand extends BranchNode {
117
122
class List extends BranchNode {
118
123
@memoizeAccessor
119
124
get children ( ) : ASTNode [ ] {
120
- const separatorOpIndex = _ . findLastIndex ( this . tokens , token => token instanceof Scanner . Semicolon ) ;
125
+ const separatorOpIndex = _ . findLastIndex ( this . tokens , isEndOfCommand ) ;
121
126
122
127
if ( separatorOpIndex !== - 1 ) {
123
128
return [
Original file line number Diff line number Diff line change @@ -147,6 +147,16 @@ export class DoubleQuotedStringLiteral extends StringLiteral {
147
147
}
148
148
}
149
149
150
+ export class NewLine extends Token {
151
+ get value ( ) {
152
+ return this . raw ;
153
+ }
154
+
155
+ get escapedValue ( ) {
156
+ return this . value as EscapedShellWord ;
157
+ }
158
+ }
159
+
150
160
export class Invalid extends Token {
151
161
get value ( ) {
152
162
return this . raw . trim ( ) ;
@@ -157,7 +167,13 @@ export class Invalid extends Token {
157
167
}
158
168
}
159
169
170
+ // All these regex start ^ so that we can look only at the first token. Maybe that should
171
+ // be part of the scanner so that the regex can be just for the token
160
172
const patterns = [
173
+ {
174
+ regularExpression : / ^ ( \n ) / ,
175
+ tokenConstructor : NewLine ,
176
+ } ,
161
177
{
162
178
regularExpression : / ^ ( \s * \| \s * ) / ,
163
179
tokenConstructor : Pipe ,
Original file line number Diff line number Diff line change 289
289
color : var (--green-color );
290
290
}
291
291
292
+ .job-header div {
293
+ white-space : pre;
294
+ }
295
+
292
296
.output {
293
297
white-space : pre-wrap;
294
298
position : relative;
You can’t perform that action at this time.
0 commit comments