• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / vscode-brightscript-language / #2719

24 Aug 2022 12:51PM UTC coverage: 41.691% (+0.02%) from 41.675%
#2719

push

TwitchBronBron
2.35.0

477 of 1427 branches covered (33.43%)

Branch coverage included in aggregate %.

1126 of 2418 relevant lines covered (46.57%)

7.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.62
/src/GlobalStateManager.ts
1
import * as vscode from 'vscode';
1✔
2

3
export class GlobalStateManager {
1✔
4
    constructor(
5
        private context: vscode.ExtensionContext
8✔
6
    ) {
7
        this.updateFromVsCodeConfiguration();
8✔
8
        vscode.workspace.onDidChangeConfiguration(() => this.updateFromVsCodeConfiguration());
8✔
9
    }
10

11
    private keys = {
8✔
12
        lastRunExtensionVersion: 'lastRunExtensionVersion',
13
        lastSeenReleaseNotesVersion: 'lastSeenReleaseNotesVersion',
14
        sendRemoteTextHistory: 'sendRemoteTextHistory'
15
    };
16
    private remoteTextHistoryLimit: number;
17
    private remoteTextHistoryEnabled: boolean;
18

19
    private updateFromVsCodeConfiguration() {
20
        let config: any = vscode.workspace.getConfiguration('brightscript') || {};
8!
21
        this.remoteTextHistoryLimit = (config.sendRemoteTextHistory || { limit: 30 }).limit;
8✔
22
        this.remoteTextHistoryEnabled = config.sendRemoteTextHistory?.enabled;
8!
23
    }
24

25
    public get lastRunExtensionVersion() {
26
        return this.context.globalState.get(this.keys.lastRunExtensionVersion);
8✔
27
    }
28
    public set lastRunExtensionVersion(value: string) {
29
        void this.context.globalState.update(this.keys.lastRunExtensionVersion, value);
7✔
30
    }
31

32
    public get lastSeenReleaseNotesVersion() {
33
        return this.context.globalState.get(this.keys.lastSeenReleaseNotesVersion);
×
34
    }
35
    public set lastSeenReleaseNotesVersion(value: string) {
36
        void this.context.globalState.update(this.keys.lastSeenReleaseNotesVersion, value);
7✔
37
    }
38

39
    public get sendRemoteTextHistory(): string[] {
40
        return this.context.globalState.get(this.keys.sendRemoteTextHistory) ?? [];
×
41
    }
42

43
    public set sendRemoteTextHistory(history: string[]) {
44
        history = history ?? [];
×
45
        // only update the results if the user has the the history enabled
46
        if (this.remoteTextHistoryEnabled) {
×
47
            // limit the number of entries saved to history
48
            history.length = Math.min(history.length, this.remoteTextHistoryLimit);
×
49
            void this.context.globalState.update(this.keys.sendRemoteTextHistory, history);
×
50
        }
51
    }
52

53
    public addTextHistory(value: string) {
54
        if (value !== '' && this.remoteTextHistoryEnabled) {
×
55
            let history = this.sendRemoteTextHistory;
×
56
            const index = history.indexOf(value);
×
57
            if (index > -1) {
×
58
                // Remove this entry to prevent duplicates in the saved history
59
                history.splice(index, 1);
×
60
            }
61

62
            // Add the the start of the array so that the history is most resent to oldest
63
            history.unshift(value);
×
64

65
            this.sendRemoteTextHistory = history;
×
66
        }
67
    }
68

69
    /**
70
     * Clear all known global state values for this extension
71
     */
72
    public clear() {
73
        for (let i in this.keys) {
×
74
            const key = this.keys[i];
×
75
            this[key] = undefined;
×
76
        }
77
    }
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc