public getConnections()

in src/connectionconfig/connectionconfig.ts [56:86]


    public getConnections(getWorkspaceConnections: boolean): IConnectionProfile[] {
        let profiles: IConnectionProfile[] = [];
        let compareProfileFunc = (a, b) => {
            // Sort by profile name if available, otherwise fall back to server name or connection string
            let nameA = a.profileName ? a.profileName : (a.server ? a.server : a.connectionString);
            let nameB = b.profileName ? b.profileName : (b.server ? b.server : b.connectionString);
            return nameA.localeCompare(nameB);
        };

        // Read from user settings
        let userProfiles = this.getProfilesFromSettings();

        userProfiles.sort(compareProfileFunc);
        profiles = profiles.concat(userProfiles);

        if (getWorkspaceConnections) {
            // Read from workspace settings
            let workspaceProfiles = this.getProfilesFromSettings(false);
            workspaceProfiles.sort(compareProfileFunc);
            profiles = profiles.concat(workspaceProfiles);
        }

        if (profiles.length > 0) {
            profiles = profiles.filter(conn => {
                // filter any connection missing a connection string and server name with sample that's shown by default
                return conn.connectionString || conn.host !== LocalizedConstants.SampleServerName;
            });
        }

        return profiles;
    }