This repository has been archived by the owner on Jul 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/lostintangent/vscode-prof…
…ile-switcher into lostintangent-master
- Loading branch information
Showing
8 changed files
with
168 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ node_modules | |
*.vsix | ||
.ionide | ||
test-results.xml | ||
.test-profiles | ||
.test-profiles | ||
*.orig |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as vscode from "vscode"; | ||
import * as vsls from "vsls"; | ||
import Config from "./config"; | ||
|
||
export async function initialize( | ||
context: vscode.ExtensionContext, | ||
config: Config, | ||
activateProfileHandler: (profile: string) => void | ||
) { | ||
// Check to see if the end-user has the Live Share | ||
// extension installed, and if not, exit early. | ||
const liveShare = await vsls.getApi(); | ||
if (!liveShare) { | ||
return; | ||
} | ||
|
||
// Begin listening for the beginning and end of Live | ||
// Share sessions, in case we need to switch profiles. | ||
liveShare.onDidChangeSession(e => { | ||
// If the end-user never set a Live Share profile, then | ||
// there's nothing we need to do. Note that we're calling | ||
// this here, instead of as part of the activation flow, | ||
// so that the end-user can set their profile any time | ||
// and have it take effect immediately. | ||
const liveShareProfile = config.getLiveShareProfile(); | ||
if (!liveShareProfile) { | ||
return; | ||
} | ||
|
||
if (e.session.id) { | ||
activateProfileHandler(liveShareProfile); | ||
} else { | ||
const previousProfile = config.getPreviousProfile(); | ||
if (!previousProfile) { | ||
return; | ||
} | ||
|
||
config.setPreviousProfile(undefined); | ||
activateProfileHandler(previousProfile); | ||
} | ||
}) | ||
} |