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

Add Notepad++ External Editor for Windows #4120

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cache:
- $HOME/.cache/electron-builder

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.3.2
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.5.1
- export PATH=$HOME/.yarn/bin:$PATH

install:
Expand Down
44 changes: 44 additions & 0 deletions app/src/lib/editors/win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export enum ExternalEditor {
VisualStudioCodeInsiders = 'Visual Studio Code (Insiders)',
SublimeText = 'Sublime Text',
CFBuilder = 'ColdFusion Builder',
NotepadPlusPlus = 'Notepad++',
}

export function parse(label: string): ExternalEditor | null {
Expand All @@ -36,6 +37,9 @@ export function parse(label: string): ExternalEditor | null {
if (label === ExternalEditor.CFBuilder) {
return ExternalEditor.CFBuilder
}
if (label === ExternalEditor.NotepadPlusPlus) {
return ExternalEditor.NotepadPlusPlus
}

return null
}
Expand Down Expand Up @@ -113,6 +117,21 @@ function getRegistryKeys(
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Adobe ColdFusion Builder 2016',
},
]
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}`)
Expand Down Expand Up @@ -140,6 +159,8 @@ function getExecutableShim(
return Path.join(installLocation, 'subl.exe')
case ExternalEditor.CFBuilder:
return Path.join(installLocation, 'CFBuilder.exe')
case ExternalEditor.NotepadPlusPlus:
return Path.join(installLocation, 'notepad++.exe')
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -180,6 +201,10 @@ function isExpectedInstallation(
displayName === 'Adobe ColdFusion Builder 2016') &&
publisher === 'Adobe Systems Incorporated'
)
case ExternalEditor.NotepadPlusPlus:
return (
displayName.startsWith('Notepad++') && publisher === 'Notepad++ Team'
)
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -258,6 +283,16 @@ function extractApplicationInformation(
return { displayName, publisher, installLocation }
}

if (editor === ExternalEditor.NotepadPlusPlus) {
const displayName = getKeyOrEmpty(keys, 'DisplayName')
const publisher = getKeyOrEmpty(keys, 'Publisher')
const installLocation = getKeyOrEmpty(keys, 'UninstallString').replace(
'uninstall.exe',
''
)
return { displayName, publisher, installLocation }
}

return assertNever(editor, `Unknown external editor: ${editor}`)
}

Expand Down Expand Up @@ -314,12 +349,14 @@ export async function getAvailableEditors(): Promise<
codeInsidersPath,
sublimePath,
cfBuilderPath,
notepadPlusPlusPath,
] = await Promise.all([
findApplication(ExternalEditor.Atom),
findApplication(ExternalEditor.VisualStudioCode),
findApplication(ExternalEditor.VisualStudioCodeInsiders),
findApplication(ExternalEditor.SublimeText),
findApplication(ExternalEditor.CFBuilder),
findApplication(ExternalEditor.NotepadPlusPlus),
])

if (atomPath) {
Expand Down Expand Up @@ -357,5 +394,12 @@ export async function getAvailableEditors(): Promise<
})
}

if (notepadPlusPlusPath) {
results.push({
editor: ExternalEditor.NotepadPlusPlus,
path: notepadPlusPlusPath,
})
}

return results
}
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ version: "{build}"
install:
- cmd: regedit /s script\default-to-tls12-on-appveyor.reg
- ps: Install-Product node $env:nodejs_version $env:platform
- choco install yarn
- git submodule update --init --recursive
- yarn install --force

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
# everything is terrible, but we must march on
- brew link --overwrite node@8 --force
# workaround for yarn installation issue
- curl -o- -L https://yarnpkg.com/install.sh | TERM=xterm bash
- curl -o- -L https://yarnpkg.com/install.sh | TERM=xterm bash -s -- --version 1.5.1

override:
- yarn install --force
Expand Down
5 changes: 4 additions & 1 deletion docs/technical/editor-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ The source for the editor integration on Windows is found in
These editors are currently supported:

- [Atom](https://atom.io/)
- [Visual Studio Code](https://code.visualstudio.com/) - both stable and Insiders channel
- [Visual Studio Code](https://code.visualstudio.com/)
- [Visual Studio Code (Insiders)](https://code.visualstudio.com/insiders/)
- [Sublime Text](https://www.sublimetext.com/)
- [ColdFusion Builder](https://www.adobe.com/products/coldfusion-builder.html)
- [Notepad++](https://notepad-plus-plus.org/)

These are defined in an enum at the top of the file:

Expand All @@ -38,6 +40,7 @@ export enum ExternalEditor {
VisualStudioCodeInsiders = 'Visual Studio Code (Insiders)',
SublimeText = 'Sublime Text',
CFBuilder = 'ColdFusion Builder',
NotepadPlusPlus = 'Notepad++'
}
```

Expand Down