Page MenuHomePhabricator

Syntax highlighter fails to highlight last character of text.
Closed, ResolvedPublic1 Estimated Story Points

Description

When the last character of text in the Editing window contains syntax-highlightable markup, that bit of markup is not actually processed by the highlighter. Example:

screenshot-2016-10-14-10-01-42-595700069.png (2×1 px, 122 KB)

Event Timeline

Dbrant renamed this task from Syntax highlighter should embolden bold formatting to Syntax highlighter fails to highlight last character of text..Oct 14 2016, 4:07 PM
Dbrant edited projects, added Android-app-Bugs; removed Android Design.
Dbrant updated the task description. (Show Details)

@Kaartic, I don't think anyone else is working on this (no ticket activity and no patches in review) so you're welcome to pick it up!

@Niedzielski In case I have doubts where am I to ask them ?

@Kaartic, here, the #wikimedia-mobile IRC channel, or in a Gerrit patch is fine :]

Ok. For now I have one doubt, is it a good decision to create a new class, probably titled SyntaxSymbol, to represent the symbols such as {{,''' etc. that are used to highlight text ?

I find the usage of String to represent the symbols a bit wrong ?

@Kaartic, we've mostly focused on reading functionality during my time on the team. It's not clear to me yet what long term editing goals are in the app so I'm inclined to focus on the bug at hand rather than refactoring the class to make it more extensible for features that may never come. My understanding of this issue was that it was most likely an index miscalculation and wouldn't require significant code restructuring. That said, I don't want to discourage you from improving the codebase if you find an opportunity but please do add tests for any new classes written and keep refactors distinct from fixes!

@Niedzielski I get your point. For now I'll see if I could find and fix the problem here. I will try to refactor later. I would like to do this because editing using the app may increase in the coming days. It may also teach me a lot. I would need a little help with that refactoring because I haven't created tests for classes before.

@Niedzielski it seems that the bug was in the if statement in line 220 atlast. Changing the >= to > fixed the problem.

BTW I was wrong avout that else part, it is indeed used because [[ is not same as ]]. I confused the length with the start and end symbols. :)

I also found another problem which I am fixing now. Will submit the patch soon. :)

Change 322431 had a related patch set uploaded (by Kaartic):
Fix for a problem in SyntaxHightlighter

https://gerrit.wikimedia.org/r/322431

Change 322431 merged by jenkins-bot:
Make SyntaxHighlighter correctly highlight the last word and prevent it from highlighting unmatched symbols

https://gerrit.wikimedia.org/r/322431

Testing specs: Samsung-SM-J120A, Android version 6.0.1, Wikipedia app build 2.4.184-alpha-2016-12-23. This appears to be fixed as in the screencap below (unlike the above one), the text '''bold''' is actually formatted correctly as bold text in the Editing window:

T148191.png (800×480 px, 38 KB)