Avoid having "press up" at the top of the editor go to edit the title of the note

Bug report

Environment

  • Platform:
  • Platform version:
  • App Version:

How to reproduce

  • Put the cursor at the top of a note editor
  • Press the “up” button on your keyboard
  • The cursor is now in the title of the note, rather than the editor it was in before
  • Pressing down doesn’t bring it back into the editor

This gets me all the time, so I thought I would share my experience here. Maybe we can have an optional setting to disable the “press up to go to title” feature?

Hi Michael,

Thanks for the feedback.
Let’s change the behavior where it move the focus to the title when:

-        if (cur.line === 0) {
+        if (cur.line === 0 && cur.ch === 0) {
            // then, move the focus to title

additionally, I found a bug where the cursor doesn’t properly move from the middle of the title to its end when pressing the down arrow key. I’ll fix it.
What’s your platform?

Hi @craftzdog,

Thanks for the quick reply. Personally, I would like to avoid putting the cursor in the title at all using the up arrow key. Is this possible? Or to have this configurable? It would be nice to be able to type Shift+Tab to get to the title when at the very top line of the editor, but not the up arrow imo.

Inkdrop: 5.6.2
OS: Mac M1
OS version: 12.6.8

You can create a custom command that replaces the default editor:go-line-up in your init.js like so:

inkdrop.commands.add(
  document.body,
  'custom:go-line-up',
  (event) => {
    const { cm } = inkdrop.getActiveEditor()

    if (cm) {
      cm.execCommand('goLineUp')
    }

    event.stopPropagation()
  }
})

Check out the doc page for more details on writing init.js here:

Then, bind your command with the up arrow key in your keymap.json:

{
  ".CodeMirror textarea": {
    "up": "custom:go-line-up"
  }
}

docs:

1 Like