Page MenuHomePhabricator

Differential highlighting can get thrown off by multiline comments
Closed, WontfixPublic

Description

See screenshot: the syntax highlighting isn't aware that the first line is part of a multiline comment, and then an apostrophe in that comment ends triggering rendering everything following as a string.

{F70335}

Event Timeline

Firehed raised the priority of this task from to Needs Triage.
Firehed updated the task description. (Show Details)
Firehed added a project: Differential.
Firehed added a subscriber: Firehed.

I don't think it's possible to fix this in a general way. The problem is that context isn't available in this diff, so the lexer would have to guess what preceded this block. If you use arc diff or manually diff with context (git diff -U9999) the lexer will have context and be able to highlight properly.

I'm not aware of any context-inferring lexers. We could likely adjust the lexers we control to hard-code this specific rule ("if a noninitial hunk in a context-missing diff contains '*/' before '/*', assume the missing context is '/*'"), but that seems very finnicky and obviously isn't generalizable.

Interesting. Someone on my team mentioned arc diff complaining about no content earlier, so he must have sent this one up by hand. I'd always wondered why sometimes I'd see "context not available" on diffs; I had figured it wasn't able to line something up cleanly with the previous revision/version in master/etc. Should either manually doing a git branch (as compared to arc feature) and/or pulling in changes from master daily have any impact on its use?

Honestly it's probably not worth hacking the lexer with this rule unless you have others hard-coded, and even still that seems wildly prone to breakage. I'd rather spend the time just beating an arc-based workflow into my colleagues :)

epriestley claimed this task.

Should either manually doing a git branch (as compared to arc feature) and/or pulling in changes from master daily have any impact on its use?

Neither should have an effect in the general case, but you may need to adjust your base rule. The most straightforward approach is probably to start with arc which when arc does something unexpected. That should explain what arc is doing and why. If it's doing the wrong thing, you can make it do something else by setting a base rule which corresponds to what you want it to do. If it's doing the right thing but the result doesn't make sense, let me know.

Generally, this topic is complex; there's some documentation here:

http://www.phabricator.com/docs/phabricator/article/Arcanist_User_Guide_Commit_Ranges.html

The highlighting thing isn't so hacky that I couldn't imagine implementing it at some point (we have a vaguely similar rule for inserting <?php already) but sorting out the arc workflow is definitely the better fix. Users can also use -U99999 to get context in manual diffs.

(You can also use arc diff ... --trace to see exactly what commands are being run, including the git diff command it ultimately executes to pull the changes out of the working copy.)