Codemirror issues

1.0.218 – My RPM builds – Fedora 32 Linux – GNOME desktop 3.36

So far, I really like Code Mirror. I am not sure really why to be honest, other than it is a bit prettier. Maybe that is all I needed.

But I see little glitches here and there. But I am really having trouble replicating things reliably (isn’t that so often the case?). What I have seen …

  1. I have browsed to an existing note and the whole note did not show up in the editor immediately until I … I am not sure what I did, but the note came back. Maybe tried to type something? This happened a couple times in the last week.

  2. Cursor position is sometimes not accurate. I go to edit an existing note and start typing. The cursor at first indicated it was in one position, but really it was somewhere else. And no, this was not due to a palm touch mistake on the touchpad. I do that often enough, but that is not what this is. I have even used the arrow keys to move around and I will go to a line where there are a TON of excess spaces at the end, I highlight them and delete them to clean them up, but OOOPS, the cursor what really elsewhere in the document and deleted a bunch of letters. This only seems to happen when I click into an existing note from elsewhere.

Note: I haven’t altered the CSS in userchrome.css at all. Nor userstyle.css for that matter. FYI: RFE – a default set of CSS populated in the .config/joplin-desktop directory, so that we don’t have to re-remember how to customize the CSS. I can’t recall how to look up the tags and elements and IDs and classes anymore. I digress.

-t

Thanks for reporting this, I also like the codemirror editor so I want to make sure it’s as solid as possible (more solid than ace editor).

  1. I have seen this occasionally as well, I think it is actually tied to the recent editor upgrades and will still happen on the ace editor. If you don’t mind, please try the ace editor as well and let me know if it ever happens (I’ll do the same).

  2. I have also experienced this issue with no luck reproducing. I thought maybe it was related to a bug I had with the gnome desktop. Are you also on gnome? I’ll spend more time trying to reproduce this more reliably. Hopefully we can get it fixed soon.

Nope. The issue doesn’t seem to appear (at least not yet) with the Ace Editor. The Ace Editor is also all one fontsize. Maybe that has something to do with it?

Found another thing. It’s not a bug, just a step back, IMHO: code blocks were syntax highlighted in the Ace Editor. Not so in Code Mirror. Just create a CSS codeblock for example.

```css
p.content {
  color: darkgreen;
  font-size: 115%;
}
```

Should produce something that looks like how it renders (excuse my hacked demonstration attempt here):

```css
p.content {
  color: darkgreen;
  font-size: 115%;
}
```

Look at it in Ace. Then look at it in Code Mirror. Not the end of the world (the rendering ends up highlighted, just not in the editor).

Side note: I find it interesting that discourse does not support wrapping ``` blocks in ```'s. I had to explicitely use HTML <pre> tags.

1 Like

Interesting! I didn’t realize that code blocks were ever syntax highlighted in AceEditor! Actually codemirror supports more syntax highlighting than aceeditor, but you have to manually specify each language. I added a few to start (try javascript or python) but neglected to add css. Eventually I want to add every supported language (including css). Thanks!

edit: btw here are the languages that can be supported

apl           gfm               octave       sql
asciiarmor    gherkin           oz           stex
asn.1         go                pascal       stylus
asterisk      groovy            pegjs        swift
brainfuck     haml              perl         tcl
clike         handlebars        php          textile
clojure       haskell           pig          tiddlywiki
cmake         haskell-literate  powershell   tiki
cobol         haxe              properties   toml
coffeescript  htmlembedded      protobuf     tornado
commonlisp    htmlmixed         pug          troff
crystal       http              puppet       ttcn
css           idl               python       ttcn-cfg
cypher        javascript        q            turtle
d             jinja2            r            twig
dart          jsx               rpm          vb
diff          julia             rst          vbscript
django        livescript        ruby         velocity
dockerfile    lua               rust         verilog
dtd           markdown          sas          vhdl
dylan         mathematica       sass         vue
ebnf          mbox              scheme       wast
ecl           meta.js           shell        webidl
eiffel        mirc              sieve        xml
elm           mllike            slim         xquery
erlang        modelica          smalltalk    yacas
factor        mscgen            smarty       yaml
fcl           mumps             solr         yaml-frontmatter
forth         nginx             soy          z80
fortran       nsis              sparql
gas           ntriples          spreadsheet

GitHub has a supported list somewhere. I think ace does as well.

I’ve posted the list of supported languages in Ace Editor there: AutoHotkey / AHK Syntax Support

So I guess we should at least support those in Ace Editor, but it can be more than that too. Ideally we’d add support for let’s say the top 50 most popular languages but it’s difficult to find such a list.

And yes as T0dd mentioned in the other thread we should also support at least “plaintext” (maybe “text” also too but I think only “plaintext” works in Ace Editor)

Sorry. I'm jumping around threads. Yeah, some zero highlight mode (plaintext or whatever) is a must. Personally, I wish the various editors would just treat unadorned ``` as no highlight. Hey! We have that now with Code Mirror. :wink: I kid.

Otherwise, top languages to start. Also markup schemas (TeX, reStructured text, docbook, etc). Anyway. Some kind of prioritized support and then let others slowly be added? Is it a PITA to just support "everything"? Is it a size issue?

Issue:

CodeMirror indents code-like things (eg. <span style="color: green">Some Text</span>)

A. The bounce of the cursor is annoying. There is enough already in this application.
B. It indents 4 spaces. Which, since this is a markdown editor, that fancy HTML I wrote is suddenly a text block and the HTML is ignored.

I can’t reproduce this, when is it indenting for you?
image

Span is probably not the best example, but … I just did a quick example and screenshotted it. See attached.

Yes that makes more sense! I’ll look into this, should be pretty easy to disable. Thanks.

Good news! I was able to reliably reproduce this and have prepared a fix! Take a look on github

And as an update for what you have reported, I still haven’t been able to reproduce issue number 1 (slow loading note in editor). The syntax highlighting (and loading css in general) is next on my codemirror todo list!

1 Like

(I'm not sure if you are aware about this issue)
In the "Code Mirror" presentation there is a part about search :

I activate code mirror but it don't put in brightening the searches, and markdown syntax are not searched inside one note, and also with Ctrl+G

Hi @Dino

That announcement is saying that it will be possible to add that behaviour, it is currently not implemented. You can follow the progress on github.

1 Like

Thanks you, that's a good info :slightly_smiling_face: