@@ -13,16 +13,16 @@ const decoration = vscode.window.createTextEditorDecorationType({
13
13
14
14
let removeHighlightTimeout = false ;
15
15
16
- const highlight = lineNumber => {
16
+ const highlight = ( fromLine , toLine ) => {
17
17
const range = new vscode . Range (
18
- new vscode . Position ( lineNumber , lineNumber ) ,
19
- new vscode . Position ( lineNumber , lineNumber ) )
18
+ new vscode . Position ( fromLine , 0 ) ,
19
+ new vscode . Position ( toLine , 0 ) ) ;
20
20
const editor = vscode . window . activeTextEditor ;
21
21
22
22
clearTimeout ( removeHighlightTimeout ) ;
23
23
editor . setDecorations ( decoration , [ range ] ) ;
24
- removeHighlightTimeout = setTimeout ( ( ) =>
25
- editor . setDecorations ( decoration , [ ] ) ,
24
+ removeHighlightTimeout = setTimeout (
25
+ ( ) => editor . setDecorations ( decoration , [ ] ) ,
26
26
10000 ) ;
27
27
} ;
28
28
@@ -49,17 +49,20 @@ twitch.on('message', (channel, tags, message, self) => {
49
49
}
50
50
51
51
try {
52
- const matches = / ^ ( \d + ) ( .* ) $ / . exec ( message . trim ( ) ) ;
53
- const lineNumber = parseInt ( matches [ 1 ] ) ;
54
- let text = matches [ 2 ] . trim ( ) ;
52
+ const matches = / ^ ( \d + ) ( [ - , : ] \d + ) ? ( .* ) $ / . exec ( message . trim ( ) ) ;
53
+ const fromLine = parseInt ( matches [ 1 ] ) ;
54
+ const toLine = ( matches [ 2 ] && parseInt ( matches [ 2 ] . substring ( 1 ) ) )
55
+ || fromLine ;
55
56
56
- if ( lineNumber <= 0 ) return ;
57
+ if ( fromLine <= 0 || toLine < fromLine ) return ;
58
+
59
+ let text = matches [ 3 ] . trim ( ) ;
57
60
58
61
if ( text . length === 0 ) text = 'No message' ;
59
62
60
63
vscode . window . showInformationMessage (
61
- `${ tags [ 'display-name' ] } is highlighting line ${ lineNumber } : ${ text } ` )
62
- highlight ( lineNumber - 1 ) ;
64
+ `${ tags [ 'display-name' ] } is highlighting lines ${ fromLine } - ${ toLine } : ${ text } ` )
65
+ highlight ( fromLine - 1 , toLine - 1 ) ;
63
66
}
64
67
catch ( err ) {
65
68
vscode . window . showErrorMessage ( err ) ;
0 commit comments