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

Optimized closing characters. #41

Merged
merged 3 commits into from
Dec 7, 2020
Merged

Conversation

PrestonHager
Copy link
Contributor

When typing a closing character for example the double quote ("), any closing characters inside this are also closed. This is good unless the characters are escaped by a backslash (\). When typing "\" you will get a doubly closed quote, such that the editor displays "\""". This is an invalid string in most editors. Instead, the editor should display "\"" which is a valid string. This request fixes this by testing for a backslash in the character before the cursor.

@antonmedv
Copy link
Owner

If you type " in the end of "some str you still get wrong result. I think this corner case just can be committed. Also what if escape char is different? For example in Bash it is '''. And in Joylang it is ^.

@PrestonHager
Copy link
Contributor Author

Can we add another option for the escape character then? All the large code editors allow for escape characters to be used inside of strings like this. For more efficiency, you can also change the codeBefore to just get the first character before the cursor instead of all of the code before. Same with codeAfter.

@PrestonHager
Copy link
Contributor Author

Also, CodeJar tends to be used with more common languages like HTML, JS, Python, C, than with Bash or Joylang. In this sense, these are the corner cases that can be ignored as most common languages use the backslash to escape characters.

@antonmedv
Copy link
Owner

Can you upload your solution to https://codesandbox.io/? I'd like to test it.

@PrestonHager
Copy link
Contributor Author

Yeah, here it is: https://k78pn.csb.app/

@antonmedv
Copy link
Owner

Yes, works really good. Just wondering is it make sense to also escape brackes?

(\()

Maybe apply this only to ' and "? What do you think?

@PrestonHager
Copy link
Contributor Author

Yeah, that seems more ergonomic, it does add one extra condition but that shouldn't harm processing time too much, especially in more modern browsers. I added that condition to the fork by adding an escapeCharacter condition.

codejar.ts Outdated Show resolved Hide resolved
@antonmedv antonmedv merged commit a599705 into antonmedv:master Dec 7, 2020
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.

None yet

2 participants