Make syntax highlighting optional in SourceActivity

doetoe avatardoetoe created an issue

Original title: Problem opening files with extension .org

Great app! I found an issue though: I have several files with extension .org in my repositories (for emacs with org-mode). When I open any other file (for as far as I tried), there is no problem, but when I open a file with this extension I get a blank screen and the processor use goes up to somewhere around 50%. I can open org-mode files that do not have the extension .org (so it is probably not the file contents).

Comments (18)

  1. Juha Kuitunen

    Can you test if you can get correct data from API with another program like curl?


    If it's a private repo, you may need to authenticate by adding --user username:password to that previous command.

    Anyway, I think this may be related to prettify.js.

  2. doetoe

    Sorry I didn't try this earlier myself, and I jumped to conclusions. I tried one of these and it does work. My org-mode files tend to be much longer than other text mode files, and it looks like this was the reason. I now opened one again, of 215kB, and after around 4 minutes at 50% (one full core) on a dual core at 800MHz it did actually show the file contents. It looks like there is no issue after all (apart from maybe the efficiency of prettification). Apologies again, and thanks for your time.

  3. Juha Kuitunen

    What if we first load our source code into webview but then we let it complete loading without calling prettyPrint(). In this point we should have code visible without highlighting. Then using something like this jQuery

    $(window).load(function () {

    to add highlighting as soon as possible.

  4. Tobias Duehr

    Juha Kuitunen we are not using jQuery right now and I also think it is too heavy weight for this task. The process looks like this:

    1. We open the WebView and load the empty source.html
    2. source.html loads it's resources (css, js) and "paints" the (still empty) DOM
    3. The JS at the end of source.html kicks in, after the DOM is ready
    4. We trigger the getFilename function to receive the filename
    5. Depending on the filetype we get the file contents with getCode or getRawCode
    6. additional functions (Markdown, prettyPrint) are triggered

    I actually don't see much room to optimize this and frankly, I also don't see why syntax highlighting should be made optional. Right now Prettify is disabled for files larger than 10000 letters and I think that's reasonable enough.

    A point I have to agree with, is that we should provide more cases for other file types (like txt and org) and shouldn't just run prettify over everything.

  5. doetoe

    Tobias Duehr It must be something other than prettify then, my specific 215kB file opens instantly using a different text editor (jota, to be precise), but takes a long time at full processor load to open from bitbeaker. A smaller (org-mode) file I have in my repository (13188 characters) opens in a few seconds, and actually shows up (somewhat randomly) coloured. Could it be the process of colouring/syntax highlighting that makes it so hard to open a large file? (I had somehow assumed that this was what prettification did)

  6. doetoe

    Apologies for the late reaction. I am not sure if prettify is active, but I just triend a 80000 character file, and the words are shown coloured (is that what prettify does?). If not prettify, some other heavy processing must be involved in opening the file, because it takes about a minute in which one of the cores of my phone is at 100%

  7. Juha Kuitunen

    I don't like that 10k limit. Some of our own files does not get highlighted anymore :D

    Now that we have an Activity for managing settings, we can customize this without making global changes affecting all bitbeaker's users.

  8. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.