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

Update syntax-related code to use new TextBuffer LanguageMode API (part 1) #15713

merged 19 commits into from Sep 25, 2017


None yet
2 participants

maxbrunsfeld commented Sep 21, 2017

Refs atom/text-buffer#260

This is the first in a series of PRs to make Atom's syntax related features more flexible.

Currently, code related to auto-indentation and code folding is mostly implemented in a private class called LanguageMode, which is constructed with a TextEditor instance, and implements most of its functionality by directly manipulating the editor.

This PR removes the LanguageMode class and reimplements its functionality in the existing TokenizedBuffer class, in a way that does not need to manipulate the editor directly. For example, instead of performing folds directly, the TokenizedBuffer exposes several pure methods for determining which buffer ranges should be folded.

I converted the TokenizedBuffer and its test to JS. For the tests that were previously in, I have either moved them into tokenized-buffer-spec.js or moved them into a new test file - text-editor-test.js. I created that new file because I had already converted these tests to JS before realizing that some of them were really about TextEditor and not TokenizedBuffer, and I didn't want to convert the entirety of to JS yet. Since the file is so large, we may want to do the conversion gradually.

/cc @nathansobo

maxbrunsfeld added some commits Sep 21, 2017

Move folding logic from LanguageMode to TokenizedBuffer
* Restate the folding logic to not *use* the TextEditor, but instead to
*return* ranges which can be folded by the editor.
* Convert the LanguageMode spec to JS
Rename language-mode-spec.js to text-editor-spec.js
This gets the ball rolling toward converting the text editor specs to JS

@maxbrunsfeld maxbrunsfeld changed the title from Update syntax-related code to use new TextBuffer LanguageMode API to Update syntax-related code to use new TextBuffer LanguageMode API (part 1) Sep 24, 2017


This comment has been minimized.

Show comment
Hide comment

nathansobo Sep 25, 2017


Nice to see some conversions to JS. Liking your overall plan.


nathansobo commented Sep 25, 2017

Nice to see some conversions to JS. Liking your overall plan.

@maxbrunsfeld maxbrunsfeld merged commit 121ede5 into master Sep 25, 2017

3 checks passed

ci/circleci Your tests passed on CircleCI!
continuous-integration/appveyor/pr AppVeyor build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed

@maxbrunsfeld maxbrunsfeld deleted the mb-use-language-mode-api branch Sep 25, 2017

@maxbrunsfeld maxbrunsfeld referenced this pull request Nov 23, 2017


Use new TextBuffer LanguageMode API #16087

2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment