Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Changes to allow backward compatibility with plain ole CodeMirror themes #8673

Merged
merged 1 commit into from
Aug 6, 2014
Merged

Changes to allow backward compatibility with plain ole CodeMirror themes #8673

merged 1 commit into from
Aug 6, 2014

Conversation

MiguelCastillo
Copy link
Contributor

Loading theme files directly instead of a package breaks old themes; e.g. vanilla codemirror themes. The issue is caused by adding the file extension as part of the theme name. This logic was to handle edge cases when themes had the same filename but different extensions, but this edge case should really be resolved by giving files a better name. This was important in earlier impls of themes that provided an interface to load all the theme files in a diretory (loadDirectory) but that interface was removed a while ago.

@dangoor dangoor self-assigned this Aug 6, 2014
dangoor added a commit that referenced this pull request Aug 6, 2014
Changes to allow backward compatibility with plain ole CodeMirror themes
@dangoor dangoor merged commit d7d394e into adobe:master Aug 6, 2014
@dangoor
Copy link
Contributor

dangoor commented Aug 6, 2014

Thanks for the fix!


this.file = file;
this.name = options.name || (options.title || fileName).toLocaleLowerCase().replace(/[\W]/g, '-');
this.name = options.name || (options.title || fileName.replace(/.[\w]+$/gi, '')).toLocaleLowerCase().replace(/[\W]/g, '-');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, didn't you mean replace(/\.[\w]+$/gi, '') (escaped dot)?
You don't need the i option, btw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, and what about double extensions like .css.min?
We should maybe add an unit test for that, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had escaped initially, but when I tested it it didn't make a difference. Check it out http://regex101.com/r/iI6oQ0/1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, yeah, escaping the dot is required because "indexhtml" matches the regex as it stands now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, these are edge cases for things that aren't hit in core usage of the feature anyhow...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to make sure the stuff works as expected though so I am make another PR with the dot escaped. Good catch guys!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants