@@ -19,6 +19,7 @@ import { LineDecoration } from 'vs/editor/common/viewLayout/lineDecorations';
19
19
import { RunOnceScheduler } from 'vs/base/common/async' ;
20
20
import { IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents' ;
21
21
import { Position } from 'vs/editor/common/core/position' ;
22
+ import { Range } from 'vs/editor/common/core/range' ;
22
23
23
24
class StickyScrollController extends Disposable implements IEditorContribution {
24
25
@@ -61,6 +62,7 @@ class StickyScrollController extends Disposable implements IEditorContribution {
61
62
this . _editor . addOverlayWidget ( this . stickyScrollWidget ) ;
62
63
this . _sessionStore . add ( this . _editor . onDidChangeModel ( ( ) => this . _update ( true ) ) ) ;
63
64
this . _sessionStore . add ( this . _editor . onDidScrollChange ( ( ) => this . _update ( false ) ) ) ;
65
+ this . _sessionStore . add ( this . _editor . onDidChangeHiddenAreas ( ( ) => this . _update ( true ) ) ) ;
64
66
this . _sessionStore . add ( this . _editor . onDidChangeModelTokens ( ( e ) => this . _onTokensChange ( e ) ) ) ;
65
67
this . _sessionStore . add ( this . _editor . onDidChangeModelContent ( ( ) => this . _updateSoon . schedule ( ) ) ) ;
66
68
this . _sessionStore . add ( this . _languageFeaturesService . documentSymbolProvider . onDidChange ( ( ) => this . _update ( true ) ) ) ;
@@ -92,6 +94,12 @@ class StickyScrollController extends Disposable implements IEditorContribution {
92
94
this . _cts = new CancellationTokenSource ( ) ;
93
95
await this . _updateOutlineModel ( this . _cts . token ) ;
94
96
}
97
+ const hiddenRanges : Range [ ] | undefined = this . _editor . _getViewModel ( ) ?. getHiddenAreas ( ) ;
98
+ if ( hiddenRanges ) {
99
+ for ( const hiddenRange of hiddenRanges ) {
100
+ this . _ranges = this . _ranges . filter ( range => { return ! ( range [ 0 ] >= hiddenRange . startLineNumber && range [ 1 ] <= hiddenRange . endLineNumber + 1 ) ; } ) ;
101
+ }
102
+ }
95
103
this . _renderStickyScroll ( ) ;
96
104
}
97
105
@@ -202,12 +210,12 @@ class StickyScrollController extends Disposable implements IEditorContribution {
202
210
if ( ! beginningLinesConsidered . has ( start ) ) {
203
211
if ( topOfElementAtDepth >= topOfEndLine - 1 && topOfElementAtDepth < bottomOfEndLine - 2 ) {
204
212
beginningLinesConsidered . add ( start ) ;
205
- this . stickyScrollWidget . pushCodeLine ( new StickyScrollCodeLine ( start , this . _editor , - 1 , bottomOfEndLine - bottomOfElementAtDepth ) ) ;
213
+ this . stickyScrollWidget . pushCodeLine ( new StickyScrollCodeLine ( start , depth , this . _editor , - 1 , bottomOfEndLine - bottomOfElementAtDepth ) ) ;
206
214
break ;
207
215
}
208
- else if ( bottomOfElementAtDepth > bottomOfBeginningLine - 1 && bottomOfElementAtDepth < bottomOfEndLine - 1 ) {
216
+ else if ( bottomOfElementAtDepth > bottomOfBeginningLine && bottomOfElementAtDepth < bottomOfEndLine - 1 ) {
209
217
beginningLinesConsidered . add ( start ) ;
210
- this . stickyScrollWidget . pushCodeLine ( new StickyScrollCodeLine ( start , this . _editor , 0 , 0 ) ) ;
218
+ this . stickyScrollWidget . pushCodeLine ( new StickyScrollCodeLine ( start , depth , this . _editor , 0 , 0 ) ) ;
211
219
}
212
220
} else {
213
221
this . _ranges . splice ( index , 1 ) ;
@@ -229,7 +237,7 @@ class StickyScrollCodeLine {
229
237
230
238
public readonly effectiveLineHeight : number = 0 ;
231
239
232
- constructor ( private readonly _lineNumber : number , private readonly _editor : IActiveCodeEditor ,
240
+ constructor ( private readonly _lineNumber : number , private readonly _depth : number , private readonly _editor : IActiveCodeEditor ,
233
241
private readonly _zIndex : number , private readonly _relativePosition : number ) {
234
242
this . effectiveLineHeight = this . _editor . getOption ( EditorOption . lineHeight ) + this . _relativePosition ;
235
243
}
@@ -294,8 +302,9 @@ class StickyScrollCodeLine {
294
302
root . onclick = e => {
295
303
e . stopPropagation ( ) ;
296
304
e . preventDefault ( ) ;
297
- this . _editor . revealLine ( this . _lineNumber ) ;
305
+ this . _editor . revealPosition ( { lineNumber : this . _lineNumber - this . _depth + 1 , column : 1 } ) ;
298
306
} ;
307
+
299
308
root . onmouseover = e => {
300
309
innerLineNumberHTML . style . background = `var(--vscode-editorStickyScrollHover-background)` ;
301
310
lineHTMLNode . style . backgroundColor = `var(--vscode-editorStickyScrollHover-background)` ;
@@ -345,7 +354,7 @@ class StickyScrollWidget implements IOverlayWidget {
345
354
constructor ( public readonly _editor : ICodeEditor ) {
346
355
this . rootDomNode = document . createElement ( 'div' ) ;
347
356
this . rootDomNode . style . width = '100%' ;
348
- this . rootDomNode . style . boxShadow = `var(--vscode-scrollbar-shadow) 0 6px 6px -6px` ; // '0px 0px 8px 2px #000000';
357
+ this . rootDomNode . style . boxShadow = `var(--vscode-scrollbar-shadow) 0 6px 6px -6px` ;
349
358
}
350
359
351
360
get codeLineCount ( ) {
0 commit comments