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

fix wrong state being passed to indenting functions #3930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WilliamMEverett
Copy link

Currently, editor.js passes a linestate to the mode checkOutdent, getNextLineIndent, and autoOutdent functions. It also passes the line. The idea is that the function can then reconstruct the tokens of the line using starting state and the line. From other examples I have seen, this is how it is supposed to be used. The problem is, editor.js currently passes the state at the end of the line. This is not very useful, since you cannot get the tokens of a line using the line text and the end state. (at least not reliably)

Issue #, if available:

*Description of changes:
editor.js:1037 is changed from "var lineState = session.getState(cursor.row);" to "var lineState = session.getState(cursor.row - 1);"

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Apr 12, 2019

Codecov Report

Merging #3930 into master will increase coverage by <.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3930      +/-   ##
==========================================
+ Coverage    69.1%   69.11%   +<.01%     
==========================================
  Files         514      514              
  Lines       49605    49605              
  Branches     9385     9385              
==========================================
+ Hits        34282    34284       +2     
+ Misses      15323    15321       -2
Impacted Files Coverage Δ
lib/ace/editor.js 78.01% <75%> (ø) ⬆️
lib/ace/mode/markdown.js 75.86% <0%> (+6.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 660cc3b...1e142ed. Read the comment docs.

@nightwing
Copy link
Member

This seems reasonable, but it is not clear what would be the effect on existing modes. Did you make this change to fix an issue in one of the modes, or to use the state in a mode that you are creating?

@WilliamMEverett
Copy link
Author

We made the change to use in a state we created. And you're right, I don't know exactly what effect it will have on existing modes.

That having been said, I think the way it is now is clearly a bug. If you look at lib/ace/mode/javascript.js : 60,
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
You'll see this makes no sense if 'state' is the state at the end of the line rather than the beginning. I think this is a case where it is essentially an accident that it currently works.

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

Successfully merging this pull request may close these issues.

None yet

4 participants