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

When user types tab, translate it into spaces for consistency #656

Merged
merged 1 commit into from
Dec 6, 2016

Conversation

asolove
Copy link
Contributor

@asolove asolove commented Dec 6, 2016

Hello, you wonderful Eve people!

As I started working on my first Eve project, I noticed something odd. Code blocks that looked fine in the browser IDE were saved to disk with odd indentation inconsistencies. Here's an example:

screen shot 2016-12-06 at 10 40 44 am

It turns out that when the editor automatically indents inside code blocks, it adds a soft tab of two spaces. But when the user hits the tab key, CodeMirror was adding a literal tab and displaying it with a width of two spaces. So when the code is saved to disk, some lines are indented two spaces (if they came from auto-indent) and some were indented with tabs (because I indented them)

Luckily there's a length conversation about soft tabs over in the CodeMirror issues and it had a pretty simple solution. I've ported that straight over here and assumed it should just live as a CodeMirror hack in those key options rather than getting into the Editor level. If you want this actually in Editor, it looks like we'd have to add some more typings to expose the CM methods this uses.

Thanks for Eve! Hope this is helpful.

…ion.

Before this, CodeMirror was storing literal tabs. They align in the IDE because it has tab size set to 2, but are inconsistent when saved to disk or viewed in another editor. The issue is discussed and my solution comes from this CodeMirror thread: codemirror/codemirror5#988
Copy link
Contributor

@ibdknox ibdknox left a comment

Choose a reason for hiding this comment

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

👍 Thanks!

@ibdknox ibdknox merged commit d9713fe into witheve:master Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants