Odd editing behaviour: JSON code saved in Markdown documents

I am using DEVONthink Pro 4.4 running on macOS 27.0.

I have a number of JSON scripts saved for reference, under various Markdown headings, in Markdown documents. (So, for example, each Markdown document would contain two or three separately displayed JSON scripts, interspersed with Markdown headings.) The JSON is all correctly displayed in preview mode.

When I edit any of the scripts in DEVONthink edit mode the cursor jumps around (most but not all of the time) when I use Backspace to delete characters—making it quite a challenge to edit the displayed scripts.

Stephen

Perhaps showing the MD and a screenshot of the preview might be helpful.

I was afraid someone was going to say that. Unfortunately, I’m not in a position to share anything just at the moment. If nobody can reproduce it, once I’m able to I’ll share.

Stephen

Well, at least tell us how you put the JSON in the MD – do you use a fenced code block like
```json
MyJSONObject here
```
or something else? What exactly?

Or share a dummy example not using real data.

BTW: JSON is not “script”. It is data. Nothing ever gets executed in/by/with JSON. It is a way to serialize some data types. Notably not even dates unless you add some code to handle that :wink:

Yes, everything was in proper fenced code blocks exactly as you showed.

Here is an example with which I can reproduce the issue when using Backspace to edit it—in some places, but not others (it appears random).

{
  "items": [
    {
      "title": "All-in-one mode",
      "subtitle": "Choose your CleanShot utility on screen",
      "arg": "all-in-one",
      "icon": {
        "path": "./Images/All-in-one mode.png"
      },
      "uid": "all-in-one-mode"
    },
    {
      "title": "Annotate clipboard image",
      "subtitle": "Annotate an image on the clipboard",
      "arg": "open-from-clipboard",
      "icon": {
        "path": "./Images/Annotate.png"
      },
      "uid": "Annotate clipboard image"
    },
    {
      "title": "Open Annotate",
      "subtitle": "Open the Annotate utility",
      "arg": "open-annotate",
      "icon": {
        "path": "./Images/Annotate.png"
      },
      "uid": "Open Annotate"
    },
    {
      "title": "Area capture",
      "subtitle": "Take a screenshot of a selected area on screen",
      "arg": "capture-area",
      "icon": {
        "path": "./Images/Capture area.png"
      },
      "uid": "Area capture"
    },
    {
      "title": "Area capture with self-timer",
      "subtitle": "Capture a selected area using self-timer",
      "arg": "self-timer",
      "icon": {
        "path": "./Images/Self-timer.png"
      },
      "uid": "Area capture with self-timer"
    },
    {
      "title": "Full-screen capture",
      "subtitle": "Take a screenshot of the full screen",
      "arg": "capture-fullscreen",
      "icon": {
        "path": "./Images/Capture full screen.png"
      },
      "uid": "Full-screen capture"
    },
    {
      "title": "Open history",
      "subtitle": "Open CleanShot history",
      "arg": "open-history",
      "icon": {
        "path": "./Images/Capture history.png"
      },
      "uid": "Open history"
    },
    {
      "title": "Previous area capture",
      "subtitle": "Take a screenshot using the previous area",
      "arg": "capture-previous-area",
      "icon": {
        "path": "./Images/Capture previous area.png"
      },
      "uid": "Previous area capture"
    },
    {
      "title": "Record screen",
      "subtitle": "Make a recording of the screen",
      "arg": "record-screen",
      "icon": {
        "path": "./Images/Record screen.png"
      },
      "uid": "Record screen"
    },
    {
      "title": "Scrolling capture",
      "subtitle": "Take a screenshot of a scrolling area",
      "arg": "scrolling-captu,
      "icon": {
        "path": "./Images/Scrolling capture.png"
      },
      "uid": "Scrolling capture"
    },
    {
      "title": "Text capture",
      "subtitle": "Capture text (OCR)",
      "arg": "capture-text",
      "icon": {
        "path": "./Images/Capture text.png"
      },
      "uid": "Text capture"
    },
    {
      "title": "Window capture",
      "subtitle": "Take a screenshot of a window",
      "arg": "capture-window",
      "icon": {
        "path": "./Images/Capture window.png"
      },
      "uid": "Window capture"
    }
  ]
}

(That is not, of itself, designed to work—so no criticism of it, please. It’s merely to demonstrate the problem.)

I apologise for my terminological inexactitude.

Stephen

Are you displaying the preview and edit panels side by side? What happens when preview is closed and you just view edit?

Hm. I created a new MD document and put the JSON you posted here in a fenced code block. Tried deleting characters with backspace (i.e. ⌫), no issues. I also added level one headings before and after the code block and tried again – no issues.
Tried also with side-by-side view, again no issues here. Also DT 4.4 on macOS 27.0, BTW.

Can you describe where exactly you see the problem? Or is it not reproducible?

I never use the panels side by side, so am in the edit panel without displaying the preview.

I can reproduce the problem by deleting a few characters using Backspace and then using ⌘Z to reinstate them. Again, the occurrence can be somewhat random but, one way of another, that reproduces it for me.

Edit: also reproducible with edit and preview panels side by side.

I can see the cursor jumping around after ⌘Z, but only to places where I’d modified the text before. So, I delete three characters, press ⌘Z three times and the deletion is restored. Then, the fourth ⌘Z jumps to another place in the text where I’d deleted or modified something before. But that is to be expected.

There is a line:

        "path": "./Images/Record screen.png"

Consistently, if I delete the closing quotation marks the cursor jumps somewhere else.

Weird. I don’t see that here. MacBook Pro 2023, no external screen.
Stupid question: Do you have tools like KM, BTT, Alfred or Typinator installed that could interfere?

A very reasonable question: I do use Typinator, but have the same problem even when I disable it. I also use (infrequently) KM and (constantly) Alfred but, at the moment, can’t see how either of those could be interfering.

I think I’m going to have to live with the problem for the time being.

You could try reproducing the issue with a different, preferably new and pristine, user account on your machine. At least that would show if it’s somehow related to your machine or your user.

1 Like

Disable Format > WYSIWYG editing. Do you still see the issue?

Well done – when I turn that one on, I see what @Stephen_C sees. No wonder that I couldn’t reproduce it before, since I never use WYSIWYG editing.

No. :folded_hands: Sanity returns, many thanks.

However…I need syntax highlighting in my Diaries database (for enhancing Item Links with specific search terms) so can’t turn off that globally (and it appears not to be a per database setting). I’m finding the menu item Format → WYSIWYG Editing a little strange. According to the manual, so long as I’ve enabled syntax highlighting in the global settings (which I have), I should be able to use that menu item to toggle the setting for individual documents. More often than not I find the menu item greyed out until I again flip between preview and edit modes for the relevant document.

Am I being obtuse?

I will see if I can reproduce the issue. Also, there are fixes in the next maintenance that may alleviate this issue.

Thanks so much.

1 Like

I was able to reproduce the issue, the next release will fix this too.

Very much obliged for the super support, as always.

1 Like