-
Notifications
You must be signed in to change notification settings - Fork 162
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
Change SyntaxError to underline complete last token #2574
Change SyntaxError to underline complete last token #2574
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have difficulties with the current way of underlining either, but perhaps because I know already what to anticipate.
A useful way to see the suggested behaviour is to look at modified test files. For example, here
function() quit; end;
- ^
+ ^^^^
this PR underlines the whole keyword and makes the problem more visible, while here
if false then ?what fi;
- ^
+ ^^^^^^^^^
the current behaviour points to a different location. Other examples can be seen in diffs. The suggested behaviour seems to be more user-friendly to me, and I like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am neutral in this respect,
the old and the new behaviour are equally good.
@fingolfin what are those Travis CI failures however? |
b951593
to
617c19c
Compare
@alex-konovalov should be fixed now. We'll see for sure after the tests cycled. |
Codecov Report
@@ Coverage Diff @@
## master #2574 +/- ##
==========================================
+ Coverage 74.6% 74.61% +<.01%
==========================================
Files 481 481
Lines 242383 242393 +10
==========================================
+ Hits 180837 180853 +16
+ Misses 61546 61540 -6
|
I agree that Concerning the It would be nice if the code of the token could be underlined or colored instead of having the |
Yeah, coloring tokens is on my wish list, too (along with coloring tokens on the REPL, and when printing functions inside GAP) |
617c19c
to
259b921
Compare
I quite like this, and also like the code related to tracking tokens. The |
I decided to merge this as I think there was a mild preference for merging, and also the debugging output gives us a useful test for checking if we continue tracking tokens correctly. |
This is an experimental patch, which changes the highlighting to syntax errors: instead of just pointing at the position we were when the syntax error occurred (which usually is at the end or just after the end of the problematic token), we now "underline" the whole token.
Example: Previously one got
With this PR
which I find slightly more helpful (esp. for longer expressions). For more examples, look at the changes to the test files.
Thoughts? Do people like or hate this? Or are neutral?
Note that
SymbolStartPos
andSymbolStartLine
will be useful to implement something else we discussed in St Andrews: using the scanner+reader to tokenize and parse GAP code, w/o executing or coding it; instead, to only (programmatically) determine if it syntactically valid, and to extract the tokenization (e.g. for syntax highlighting in command line prompts). For that, we want to record start and end of tokens (we might want to do this in terms of an absolute seek position for a stream, though, but that's a separate concern), amongst other things.