This repository was archived by the owner on May 21, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ import * as React from "react" ;
2
+ import { PluginManager } from "../PluginManager" ;
3
+ import { Job } from "../shell/Job" ;
4
+ import Link from "../utils/Link" ;
5
+ import { join } from "path" ;
6
+ import { colors } from "../views/css/colors" ;
7
+
8
+ PluginManager . registerOutputDecorator ( {
9
+ decorate : ( job : Job ) : React . ReactElement < any > => {
10
+ return < div style = { {
11
+ padding : "10px" ,
12
+ lineHeight : "18px" ,
13
+ } } > { job . screenBuffer . toLines ( ) . map ( ( line , index ) => {
14
+ const match = line . match ( / ^ ( .* ?) : ( \d + ) : ( .* ) $ / ) ;
15
+ if ( match ) {
16
+ const [ , path , lineNum , rest ] = match ;
17
+ if ( path && lineNum && rest ) {
18
+ const absolutePath = join ( job . environment . pwd , path ) ;
19
+ return < div key = { index . toString ( ) } >
20
+ < Link absolutePath = { absolutePath } > { path } </ Link >
21
+ < span style = { { color : colors . cyan } } > :</ span >
22
+ { lineNum }
23
+ < span style = { { color : colors . cyan } } > :</ span >
24
+ < span style = { { whiteSpace : "pre" } } > { rest } </ span >
25
+ </ div > ;
26
+ }
27
+ }
28
+ return < div key = { index . toString ( ) } > { line } </ div > ;
29
+ } ) } </ div > ;
30
+ } ,
31
+
32
+ isApplicable : ( job : Job ) : boolean => {
33
+ try {
34
+ const promptWords = job . prompt . expandedTokens . map ( t => t . escapedValue ) ;
35
+ return promptWords . length === 3 && promptWords [ 0 ] === "git" && promptWords [ 1 ] === "grep" ;
36
+ } catch ( e ) {
37
+ return false ;
38
+ }
39
+ } ,
40
+ } ) ;
You can’t perform that action at this time.
0 commit comments