Editors++ Notepad++

This commit is contained in:
say25 2020-03-08 21:33:33 -04:00
parent e5b8dccde3
commit 97000ad008
2 changed files with 43 additions and 0 deletions

View file

@ -25,6 +25,7 @@ export enum ExternalEditor {
SlickEdit = 'SlickEdit',
Webstorm = 'JetBrains Webstorm',
Phpstorm = 'JetBrains Phpstorm',
NotepadPlusPlus = 'Notepad++',
}
export function parse(label: string): ExternalEditor | null {
@ -64,6 +65,9 @@ export function parse(label: string): ExternalEditor | null {
if (label === ExternalEditor.Phpstorm) {
return ExternalEditor.Phpstorm
}
if (label === ExternalEditor.NotepadPlusPlus) {
return ExternalEditor.NotepadPlusPlus
}
return null
}
@ -352,6 +356,21 @@ function getRegistryKeys(
'SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\PhpStorm 2020.1',
},
]
case ExternalEditor.NotepadPlusPlus:
return [
// 64-bit version of Notepad++
{
key: HKEY.HKEY_LOCAL_MACHINE,
subKey:
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Notepad++',
},
// 32-bit version of Notepad++
{
key: HKEY.HKEY_LOCAL_MACHINE,
subKey:
'SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Notepad++',
},
]
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
@ -393,6 +412,8 @@ function getExecutableShim(
return Path.join(installLocation, 'bin', 'webstorm.exe')
case ExternalEditor.Phpstorm:
return Path.join(installLocation, 'bin', 'phpstorm.exe')
case ExternalEditor.NotepadPlusPlus:
return Path.join(installLocation)
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
@ -453,6 +474,10 @@ function isExpectedInstallation(
return (
displayName.startsWith('PhpStorm') && publisher === 'JetBrains s.r.o.'
)
case ExternalEditor.NotepadPlusPlus:
return (
displayName.startsWith('Notepad++') && publisher === 'Notepad++ Team'
)
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
@ -616,6 +641,13 @@ function extractApplicationInformation(
return { displayName, publisher, installLocation }
}
if (editor === ExternalEditor.NotepadPlusPlus) {
const displayName = getKeyOrEmpty(keys, 'DisplayName')
const publisher = getKeyOrEmpty(keys, 'Publisher')
const installLocation = getKeyOrEmpty(keys, 'DisplayIcon')
return { displayName, publisher, installLocation }
}
return assertNever(editor, `Unknown external editor: ${editor}`)
}
@ -679,6 +711,7 @@ export async function getAvailableEditors(): Promise<
slickeditPath,
webstormPath,
phpstormPath,
notepadPlusPlusPath,
] = await Promise.all([
findApplication(ExternalEditor.Atom),
findApplication(ExternalEditor.AtomBeta),
@ -692,6 +725,7 @@ export async function getAvailableEditors(): Promise<
findApplication(ExternalEditor.SlickEdit),
findApplication(ExternalEditor.Webstorm),
findApplication(ExternalEditor.Phpstorm),
findApplication(ExternalEditor.NotepadPlusPlus),
])
if (atomPath) {
@ -787,5 +821,12 @@ export async function getAvailableEditors(): Promise<
})
}
if (notepadPlusPlusPath) {
results.push({
editor: ExternalEditor.NotepadPlusPlus,
path: notepadPlusPlusPath,
})
}
return results
}

View file

@ -33,6 +33,7 @@ These editors are currently supported:
- [SlickEdit](https://www.slickedit.com)
- [JetBrains WebStorm](https://www.jetbrains.com/webstorm/)
- [JetBrains Phpstorm](https://www.jetbrains.com/phpstorm/)
- [Notepad++](https://notepad-plus-plus.org/)
These are defined in an enum at the top of the file:
@ -50,6 +51,7 @@ export enum ExternalEditor {
SlickEdit = 'SlickEdit',
Webstorm = 'JetBrains Webstorm',
Phpstorm = 'JetBrains Phpstorm',
NotepadPlusPlus = 'Notepad++',
}
```