-
Notifications
You must be signed in to change notification settings - Fork 17.4k
Use file suffix to load specific platform keybindings. #1456
Conversation
Example: On osx `keymap.cson` and `keymap-darwin.cson` would load. But `keymap-win32.cson` would not load.
I changed this from using a file suffix to uses the entire filename. This way it matches how menu's handle platform specific bindings. |
Fixes #1453 |
otherPlatforms = platforms.filter (name) -> name != process.platform | ||
|
||
for filePath in fs.listSync(directoryPath, ['.cson', '.json']) | ||
platform = path.basename(filePath).match(/^(\w+)\.\w+$/)?[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this regex now that you aren't using the suffix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about using path.basename(filePath, path.extname(filePath)) not in otherPlatforms
but that seemed just as ugly. Is there a cleaner way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I get it now, I prefer the basename/extname dance because then I don't have to think about what actually is in \w
in case someone reports an issue about their keymap not loading someday.
This would be clear to me:
continue if path.basename(filePath, path.extname(filePath)) in otherPlatforms
Use file suffix to load specific platform keybindings.
For Example: On OS X, keymap files named
keymap.cson
anddarwin.cson
would load, butwin32.cson
would not load.