Hyper: Preferences are opened in notepad.exe on Windows, mangling line endings

Created on 12 Dec 2016  路  15Comments  路  Source: vercel/hyper

On Windows, the settings are opened in notepad.exe which does not support line breaks. You should either use \r\n in your settings or open the settings with wordpad or any other app that supports Linux-style link breaks.

Most helpful comment

Why not simply add it as a configuration option in .hyper.js? That would be the easiest way to configure it.

All 15 comments

I think the best way to do this on Windows is to look up the default text editor in the registry at HKEY_CLASSES_ROOT\txtfile\shell\open\command. You'll get a value like %SystemRoot%\system32\NOTEPAD.EXE %1 and replace %1 with the filename.

Update: There's also a default editor setting for .js files, which would probably make more sense but also rarely be set: HKEY_CLASSES_ROOT\JSFile\Shell\Edit\Command

There are a few npm packages that simplify registry lookup, but not sure you want to bring in the overhead.

Not a bad idea, but honestly most people won't have changed their default text editor.

@mqudsi I agree. If you've got notepad++, atom, vs code, etc. configured that'd be best, but that'd be a tiny percentage of users. Lauching with wordpad is probably the best option right now.

Longer term, a fancier solution would be to check if the user has configured a text editor (look up reg key, if it's not notepad.exe use it, otherwise use wordpad) but wordpad would probably be fine.

It's too bad that .js files don't have a default text editor association on windows, it'd be much easier if shell.openItem(fullPath) would do a sane thing by default.

@tivac There is a default .js editor on Windows, and it's configurable. It's just that very few people seem to change it, and code editors (like VS Code) don't seem to set it either. The reg setting is HKEY_CLASSES_ROOT\JSFile\Shell\Edit\Command

A good recommendation in the comments on the PR is to use shell.showItemInFolder() to just show the file in the folder and allow the user to open via context menu.

Why not simply add it as a configuration option in .hyper.js? That would be the easiest way to configure it.

I am in complete agreement with @tmr232 . There should be an editor: property of the config{} object where the executable (with or without path) can be entered.

It wouldn't hurt to first default to an ENV variable first like %EDITOR% but that is much less common on windows.

I think that is a little bit circular, setting editor in a config that is supposed to be opened by editor.

Ultimately, opening the config is a once-a-month thing, no need to over complicate it. shell.showItemInFolder() is a simple and adaptive solution.

I would suggest to either use HKEY_CLASSES_ROOT\JSFile\Shell\Edit\Command to get the default editor for js files, and if not defined, fall back to Wordpad.

But avoid using notepad since loaded file is unusable as @mqudsi pointed out.

Why don't we just add Windows line endings to the default configurations file?
Any changes thereafter would conform to whatever editor the file was opened/saved in last.

Problem is even if a default editor for .js is defined (which maybe a lot of devs and so users of Hyper do anyway) Hyper still opens it in Notepad :(
If I open it manually in VCSCode (my default .js editor and which handles lines too) it is just fine.

There are three solutions:

  1. Make .hyper.js use CR+LF line endings on Windows. This is trivial.
  2. Check registry for default js editor, and open .hyper.js with that. Fallback to wordpad (see this comment).
  3. Ship with a default text editor (perhaps a plugin), such as a simple textarea with a save button.

Can't see any reason not to use both (1) and (2).

This directly inspired the development and release of the open source betterpad, a plain-text editor for Windows that doesn't suck. Fork on github.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sarneeh picture sarneeh  路  3Comments

cilice picture cilice  路  3Comments

aem picture aem  路  3Comments

legomushroom picture legomushroom  路  3Comments

laur1s picture laur1s  路  3Comments