Writing a table entry longer than the line wrap width breaks the "end" keyboard button

Steps to reproduce

  1. Create a table in the Editor
  2. When defining a header or a row of cells, write enough text that the line becomes longer than the point where it would usually wrap
  3. Press the ‘End’ key on your keyboard

Expected result

The cursor should be moved to the end of the line.

Actual result

The cursor roughly moves to the point where text would wrap. This happens regardless of whether your cursor is to the left of that point or to the right of it: if you’re further into the line, it will bring the cursor back.

I think this might be affected by the size of the window as well, but I’m not sure.

Environment

  • Operating system: Windows 10
  • Obsidian version: v0.8.12

Additional information

This is the table that I was writing when I discovered this bug:

Classe A objet pointé par A* objet référencé par A&
ne change pas durant l’execution ne peut être connu qu’au moment de l’execution ne peut être connu qu’au moment de l’execution
coïncide avec le [[Type statique 202009101142 type statique]] de A peut varier au cours de l’execution
ne coïncide pas forcément avec le type statique de A* ne coïncide pas forcément avec le type statique de A&
4 Likes

+1 on this bug, it annoys a lot when you have tables in your daily note template

I’m having this bug in Obsidian v0.10.9.
I did this video as a demonstration of the problem: https://www.youtube.com/watch?v=wjXj52AMV2o

1 Like

Yes I have this problem too. It’s somewhat annoying. As a work around I go one line lower with arrow down, press home, and then arrow left.

Since there’s a workaround this issue is no big deal for me. But if it’s something that can be easily fixed, it would be nice to have it polished. :slightly_smiling_face:

I’m on Windows with Obsidian 0.10.9.

Same problem here. Obsidian 0.10.8 on Ubuntu. 20.04

Just ran into this issue; here’s what’s happening and how it can be fixed.

(You can, of course, temporarily work around the problem by turning off “Line Wrap” under the “Editor” settings. But obviously that’s not a practical long term solution.)

Basically, the issue here is that in Obsidian’s default keymap for CodeMirror, the “End” key is bound to the goLineRight command, which is actually what you want for lines that might be wrapped (i.e. everything but tables).

So it needs to be replaced with a function that checks if the line is a table line and then executes goLineEnd instead of goLineRight. I added a proof-of-concept workaround to one of my in-progress plugins, like so:

        this.register(around(CodeMirror.commands, {goLineRight(old) {
            return function(cm) {
                const handle = cm.getLineHandle( cm.getCursor("end").line );
                return handle.styleClasses?.textClass?.split(" ").contains("HyperMD-table-row") ?
                    CodeMirror.commands.goLineEnd(cm) :
                    old(cm)
                ;
            }
        }}));

For the Obsidian core fix, It can of course be implemented without the around decorator, e.g. by adding it as a new smartEnd command that the End key is then bound to, and which then calls either goLineEnd or goLineRight as appropriate.

will be implemented in 0.11.11.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.