microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.49k stars 29.37k forks source link

Not clear what TimelineChangeEvent.reset does #94242

Closed JacksonKearl closed 4 years ago

JacksonKearl commented 4 years ago

ref #93820

I see that when this is true, the entire timeline is reset. I'm not sure what it does when false.

Using this timeline provider:

class TodayTimeline implements vscode.TimelineProvider, vscode.Disposable {
    private _onDidChange = new vscode.EventEmitter<vscode.TimelineChangeEvent>()
    onDidChange?: vscode.Event<vscode.TimelineChangeEvent> = this._onDidChange.event
    id = 'solunar-timeline.today-timeline'
    label = 'Today'

    private intervalHandle: NodeJS.Timeout;
    constructor() {
        this.intervalHandle = setInterval(() => {
            console.log('triggering today update')
            this._onDidChange.fire({ reset: true })
        }, 1000)
    }

    dispose() {
        clearInterval(this.intervalHandle)
    }

    provideTimeline(): vscode.ProviderResult<vscode.Timeline> {
        console.log('providing new today')
        return { items: [{ timestamp: Date.now(), label: 'Today', description: new Date().toTimeString() }] }
    }
}

If rest is false, provideTimeline only ever seems to get called once, and the today value doesn't ever update.

I'm not sure when reset would be false, maybe including more info about that in the docs would help clarify.

eamodio commented 4 years ago

This was a bug in the handling of reset: false it should have updated.