Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support VSCode Insiders build alongside Stable #3441

Merged
merged 9 commits into from Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 23 additions & 3 deletions app/src/lib/editors/darwin.ts
Expand Up @@ -6,6 +6,7 @@ import { assertNever } from '../fatal-error'
export enum ExternalEditor {
Atom = 'Atom',
VisualStudioCode = 'Visual Studio Code',
VisualStudioCodeInsiders = 'Visual Studio Code (Insiders)',
SublimeText = 'Sublime Text',
BBEdit = 'BBEdit',
}
Expand All @@ -14,10 +15,12 @@ export function parse(label: string): ExternalEditor | null {
if (label === ExternalEditor.Atom) {
return ExternalEditor.Atom
}

if (label === ExternalEditor.VisualStudioCode) {
return ExternalEditor.VisualStudioCode
}
if (label === ExternalEditor.VisualStudioCodeInsiders) {
return ExternalEditor.VisualStudioCodeInsiders
}
if (label === ExternalEditor.SublimeText) {
return ExternalEditor.SublimeText
}
Expand All @@ -38,7 +41,9 @@ function getBundleIdentifiers(editor: ExternalEditor): ReadonlyArray<string> {
case ExternalEditor.Atom:
return ['com.github.atom']
case ExternalEditor.VisualStudioCode:
return ['com.microsoft.VSCode', 'com.microsoft.VSCodeInsiders']
return ['com.microsoft.VSCode']
case ExternalEditor.VisualStudioCodeInsiders:
return ['com.microsoft.VSCodeInsiders']
case ExternalEditor.SublimeText:
return ['com.sublimetext.3']
case ExternalEditor.BBEdit:
Expand All @@ -56,6 +61,7 @@ function getExecutableShim(
case ExternalEditor.Atom:
return Path.join(installPath, 'Contents', 'Resources', 'app', 'atom.sh')
case ExternalEditor.VisualStudioCode:
case ExternalEditor.VisualStudioCodeInsiders:
return Path.join(
installPath,
'Contents',
Expand Down Expand Up @@ -102,9 +108,16 @@ export async function getAvailableEditors(): Promise<
> {
const results: Array<IFoundEditor<ExternalEditor>> = []

const [atomPath, codePath, sublimePath, bbeditPath] = await Promise.all([
const [
atomPath,
codePath,
codeInsidersPath,
sublimePath,
bbeditPath,
] = await Promise.all([
findApplication(ExternalEditor.Atom),
findApplication(ExternalEditor.VisualStudioCode),
findApplication(ExternalEditor.VisualStudioCodeInsiders),
findApplication(ExternalEditor.SublimeText),
findApplication(ExternalEditor.BBEdit),
])
Expand All @@ -117,6 +130,13 @@ export async function getAvailableEditors(): Promise<
results.push({ editor: ExternalEditor.VisualStudioCode, path: codePath })
}

if (codeInsidersPath) {
results.push({
editor: ExternalEditor.VisualStudioCodeInsiders,
path: codeInsidersPath,
})
}

if (sublimePath) {
results.push({ editor: ExternalEditor.SublimeText, path: sublimePath })
}
Expand Down
31 changes: 22 additions & 9 deletions app/src/lib/editors/linux.ts
Expand Up @@ -5,6 +5,7 @@ import { assertNever } from '../fatal-error'
export enum ExternalEditor {
Atom = 'Atom',
VisualStudioCode = 'Visual Studio Code',
VisualStudioCodeInsiders = 'Visual Studio Code (Insiders)',
SublimeText = 'Sublime Text',
}

Expand All @@ -17,6 +18,10 @@ export function parse(label: string): ExternalEditor | null {
return ExternalEditor.VisualStudioCode
}

if (label === ExternalEditor.VisualStudioCodeInsiders) {
return ExternalEditor.VisualStudioCode
}

if (label === ExternalEditor.SublimeText) {
return ExternalEditor.SublimeText
}
Expand All @@ -33,10 +38,8 @@ function getEditorPath(editor: ExternalEditor): Promise<string | null> {
case ExternalEditor.Atom:
return getPathIfAvailable('/usr/bin/atom')
case ExternalEditor.VisualStudioCode:
const codePath = getPathIfAvailable('/usr/bin/code')
if (codePath) {
return codePath
}
return getPathIfAvailable('/usr/bin/code')
case ExternalEditor.VisualStudioCodeInsiders:
return getPathIfAvailable('/usr/bin/code-insiders')
case ExternalEditor.SublimeText:
return getPathIfAvailable('/usr/bin/subl')
Expand All @@ -50,11 +53,14 @@ export async function getAvailableEditors(): Promise<
> {
const results: Array<IFoundEditor<ExternalEditor>> = []

const [atomPath, codePath, sublimePath] = await Promise.all([
getEditorPath(ExternalEditor.Atom),
getEditorPath(ExternalEditor.VisualStudioCode),
getEditorPath(ExternalEditor.SublimeText),
])
const [atomPath, codePath, codeInsidersPath, sublimePath] = await Promise.all(
[
getEditorPath(ExternalEditor.Atom),
getEditorPath(ExternalEditor.VisualStudioCode),
getEditorPath(ExternalEditor.VisualStudioCodeInsiders),
getEditorPath(ExternalEditor.SublimeText),
]
)

if (atomPath) {
results.push({ editor: ExternalEditor.Atom, path: atomPath })
Expand All @@ -64,6 +70,13 @@ export async function getAvailableEditors(): Promise<
results.push({ editor: ExternalEditor.VisualStudioCode, path: codePath })
}

if (codeInsidersPath) {
results.push({
editor: ExternalEditor.VisualStudioCode,
path: codeInsidersPath,
})
}

if (sublimePath) {
results.push({ editor: ExternalEditor.SublimeText, path: sublimePath })
}
Expand Down
43 changes: 38 additions & 5 deletions app/src/lib/editors/win32.ts
Expand Up @@ -8,6 +8,7 @@ import { IRegistryEntry, readRegistryKeySafe } from '../registry'
export enum ExternalEditor {
Atom = 'Atom',
VisualStudioCode = 'Visual Studio Code',
VisualStudioCodeInsiders = 'Visual Studio Code (Insiders)',
SublimeText = 'Sublime Text',
CFBuilder = 'ColdFusion Builder',
}
Expand All @@ -19,6 +20,9 @@ export function parse(label: string): ExternalEditor | null {
if (label === ExternalEditor.VisualStudioCode) {
return ExternalEditor.VisualStudioCode
}
if (label === ExternalEditor.VisualStudioCodeInsiders) {
return ExternalEditor.VisualStudioCodeInsiders
}
if (label === ExternalEditor.SublimeText) {
return ExternalEditor.SublimeText
}
Expand Down Expand Up @@ -47,9 +51,14 @@ function getRegistryKeys(editor: ExternalEditor): ReadonlyArray<string> {
return [
// 64-bit version of VSCode - not available from home page but just made available
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1',
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1',
// 32-bit version of VSCode - what most people will be using for the forseeable future
'HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1',
]
case ExternalEditor.VisualStudioCodeInsiders:
return [
// 64-bit version of VSCode - not available from home page but just made available
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1',
// 32-bit version of VSCode - what most people will be using for the forseeable future
'HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1',
]
case ExternalEditor.SublimeText:
Expand Down Expand Up @@ -84,6 +93,8 @@ function getExecutableShim(
return Path.join(installLocation, 'bin', 'atom.cmd')
case ExternalEditor.VisualStudioCode:
return Path.join(installLocation, 'bin', 'code.cmd')
case ExternalEditor.VisualStudioCodeInsiders:
return Path.join(installLocation, 'bin', 'code-insiders.cmd')
case ExternalEditor.SublimeText:
return Path.join(installLocation, 'subl.exe')
case ExternalEditor.CFBuilder:
Expand All @@ -110,8 +121,12 @@ function isExpectedInstallation(
return displayName === 'Atom' && publisher === 'GitHub Inc.'
case ExternalEditor.VisualStudioCode:
return (
(displayName === 'Microsoft Visual Studio Code' ||
displayName === 'Microsoft Visual Studio Code Insiders') &&
displayName === 'Microsoft Visual Studio Code' &&
publisher === 'Microsoft Corporation'
)
case ExternalEditor.VisualStudioCodeInsiders:
return (
displayName === 'Microsoft Visual Studio Code Insiders' &&
publisher === 'Microsoft Corporation'
)
case ExternalEditor.SublimeText:
Expand Down Expand Up @@ -157,7 +172,10 @@ function extractApplicationInformation(
return { displayName, publisher, installLocation }
}

if (editor === ExternalEditor.VisualStudioCode) {
if (
editor === ExternalEditor.VisualStudioCode ||
editor === ExternalEditor.VisualStudioCodeInsiders
) {
for (const item of keys) {
if (item.name === 'DisplayName') {
displayName = item.value
Expand Down Expand Up @@ -191,6 +209,7 @@ function extractApplicationInformation(

return { displayName, publisher, installLocation }
}

if (editor === ExternalEditor.CFBuilder) {
for (const item of keys) {
if (item.name === 'DisplayName') {
Expand Down Expand Up @@ -255,9 +274,16 @@ export async function getAvailableEditors(): Promise<
> {
const results: Array<IFoundEditor<ExternalEditor>> = []

const [atomPath, codePath, sublimePath, cfBuilderPath] = await Promise.all([
const [
atomPath,
codePath,
codeInsidersPath,
sublimePath,
cfBuilderPath,
] = await Promise.all([
findApplication(ExternalEditor.Atom),
findApplication(ExternalEditor.VisualStudioCode),
findApplication(ExternalEditor.VisualStudioCodeInsiders),
findApplication(ExternalEditor.SublimeText),
findApplication(ExternalEditor.CFBuilder),
])
Expand All @@ -276,6 +302,13 @@ export async function getAvailableEditors(): Promise<
})
}

if (codeInsidersPath) {
results.push({
editor: ExternalEditor.VisualStudioCodeInsiders,
path: codeInsidersPath,
})
}

if (sublimePath) {
results.push({
editor: ExternalEditor.SublimeText,
Expand Down