@@ -16,23 +16,23 @@ export class TopmostLineMonitor extends Disposable {
16
16
17
17
private readonly pendingUpdates = new Map < string , number > ( ) ;
18
18
private readonly throttle = 50 ;
19
- private previousEditorInfo = new Map < string , LastScrollLocation > ( ) ;
20
- public isPrevEditorCustom = false ;
19
+ private previousTextEditorInfo = new Map < string , LastScrollLocation > ( ) ;
20
+ private previousStaticEditorInfo = new Map < string , LastScrollLocation > ( ) ;
21
21
22
22
constructor ( ) {
23
23
super ( ) ;
24
24
25
25
if ( vscode . window . activeTextEditor ) {
26
26
const line = getVisibleLine ( vscode . window . activeTextEditor ) ;
27
- this . setPreviousEditorLine ( { uri : vscode . window . activeTextEditor . document . uri , line : line ?? 0 } ) ;
27
+ this . setPreviousTextEditorLine ( { uri : vscode . window . activeTextEditor . document . uri , line : line ?? 0 } ) ;
28
28
}
29
29
30
30
this . _register ( vscode . window . onDidChangeTextEditorVisibleRanges ( event => {
31
31
if ( isMarkdownFile ( event . textEditor . document ) ) {
32
32
const line = getVisibleLine ( event . textEditor ) ;
33
33
if ( typeof line === 'number' ) {
34
34
this . updateLine ( event . textEditor . document . uri , line ) ;
35
- this . setPreviousEditorLine ( { uri : event . textEditor . document . uri , line : line } ) ;
35
+ this . setPreviousTextEditorLine ( { uri : event . textEditor . document . uri , line : line } ) ;
36
36
}
37
37
}
38
38
} ) ) ;
@@ -41,12 +41,24 @@ export class TopmostLineMonitor extends Disposable {
41
41
private readonly _onChanged = this . _register ( new vscode . EventEmitter < { readonly resource : vscode . Uri , readonly line : number } > ( ) ) ;
42
42
public readonly onDidChanged = this . _onChanged . event ;
43
43
44
- public setPreviousEditorLine ( scrollLocation : LastScrollLocation ) : void {
45
- this . previousEditorInfo . set ( scrollLocation . uri . toString ( ) , scrollLocation ) ;
44
+ public setPreviousStaticEditorLine ( scrollLocation : LastScrollLocation ) : void {
45
+ this . previousStaticEditorInfo . set ( scrollLocation . uri . toString ( ) , scrollLocation ) ;
46
46
}
47
47
48
- public getPreviousEditorLineByUri ( resource : vscode . Uri ) : number | undefined {
49
- const scrollLoc = this . previousEditorInfo . get ( resource . toString ( ) ) ;
48
+ public getPreviousStaticEditorLineByUri ( resource : vscode . Uri ) : number | undefined {
49
+ const scrollLoc = this . previousStaticEditorInfo . get ( resource . toString ( ) ) ;
50
+ this . previousStaticEditorInfo . delete ( resource . toString ( ) ) ;
51
+ return scrollLoc ?. line ;
52
+ }
53
+
54
+
55
+ public setPreviousTextEditorLine ( scrollLocation : LastScrollLocation ) : void {
56
+ this . previousTextEditorInfo . set ( scrollLocation . uri . toString ( ) , scrollLocation ) ;
57
+ }
58
+
59
+ public getPreviousTextEditorLineByUri ( resource : vscode . Uri ) : number | undefined {
60
+ const scrollLoc = this . previousTextEditorInfo . get ( resource . toString ( ) ) ;
61
+ this . previousTextEditorInfo . delete ( resource . toString ( ) ) ;
50
62
return scrollLoc ?. line ;
51
63
}
52
64
0 commit comments