@@ -14,9 +14,12 @@ window.__IntelliJTools.scrollToLine = (function () {
14
14
15
15
for ( var i = 0 ; i < classes . length ; i ++ ) {
16
16
var className = classes [ i ]
17
- if ( className . match ( / ^ d a t a - l i n e - s t d i n - / ) ) {
18
- return Number ( className . substr ( "data-line-stdin-" . length ) ) ;
19
- }
17
+ }
18
+ if ( className . match ( / ^ d a t a - l i n e - s t d i n - / ) ) {
19
+ return Number ( className . substr ( "data-line-stdin-" . length ) ) ;
20
+ } else if ( className . match ( / ^ d a t a - l i n e - / ) ) {
21
+ // This is an include of another file
22
+ return - 1 ;
20
23
}
21
24
22
25
return null
@@ -39,19 +42,28 @@ window.__IntelliJTools.scrollToLine = (function () {
39
42
var startLine = 0 ;
40
43
var endY ;
41
44
var endLine = lineCount ;
45
+ var includeFound = false ;
42
46
43
47
for ( var i = 0 ; i < blocks . length ; i ++ ) {
44
48
var block = blocks [ i ]
45
49
var lineOfBlock = getLine ( block ) ;
46
- if ( lineOfBlock <= newLineToScroll ) {
50
+ if ( lineOfBlock === - 1 ) {
51
+ includeFound = true ;
52
+ } else if ( lineOfBlock <= newLineToScroll ) {
47
53
startY = calculateOffset ( block )
48
54
startLine = lineOfBlock
49
55
// there might be no further block, therefore assume that the end is at the end of this block
50
56
endY = startY + block . offsetHeight
51
- }
52
- else if ( lineOfBlock > newLineToScroll ) {
53
- endY = calculateOffset ( block )
54
- endLine = lineOfBlock - 1 ;
57
+ includeFound = false ;
58
+ } else if ( lineOfBlock > newLineToScroll ) {
59
+ if ( includeFound ) {
60
+ // if there is an include, place the view where we expect the beginning of the include
61
+ endY = startY
62
+ endLine = startLine ;
63
+ } else {
64
+ endY = calculateOffset ( block )
65
+ endLine = lineOfBlock - 1 ;
66
+ }
55
67
break
56
68
}
57
69
}
0 commit comments