jacobwhall / marktext

fork of marktext, seeking to modernize our favorite markdown editor
MIT License
114 stars 3 forks source link

Horizonal scroll bar jumps back when typing in a code block #14

Open jkwnki opened 1 year ago

jkwnki commented 1 year ago

Hi,

there's a weird behavior with code blocks.

Reproduction:

create code block. Add a line:

echo "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore" > file

append extension to file e.g. file.txt

The cursor disappears und the horizontal scroll bar jumps to beginning of code block.

Also the copy icon inside the code block is totally misplaced, particularly when working on end of line. Lets place it outside the code box:

copy

Or, if possible, it could pop up when cursor inside the code block.

What is "fence" for?

Greetings jkwnki

jacobwhall commented 1 year ago

Hey @jkwnki, I was able to reproduce this bug. Here is a specific set of steps:

  1. In File > Preferences > Editor > Misc disable "wrap text inside code blocks" in order for horizontal scroll bars to appear in code blocks
  2. Create a new file in MarkText
  3. Insert a code block at the beginning of the file using the @ shortcut
  4. Type a long line of text into the code block, until a horizontal scroll bar appears
  5. Observe that each time a character is typed, the horizontal jumps back to the beginning of the line, so that the user cannot read what they just typed

Indeed, this is no good! We shall fix. In the meantime, I recommend you enable code block wrapping in Preferences as described in step 1 above.

Also the copy icon inside the code block is totally misplaced.

To be honest, I like it where it is! It doesn't not overlap any text, and its purpose is unambiguous. Why do you feel that it should be moved to outside of the code block?

What is "fence" for?

The backtick characters used to delineate code blocks in Markdown are often called fences, e.g. in the CommonMark spec. I suppose literally writing "fence" in the bottom right corner of a code block isn't strictly necessary...

jkwnki commented 1 year ago

To be honest, I like it where it is! It doesn't not overlap any text, and its purpose is unambiguous. Why do you feel that it should be moved to outside of the code block?

Cause its overlapping :) : overlap

Edit: Oh i see, its only when "wrap text inside code blocks" is disabled.

My personal preference now is to have it turned of, so decide yourself whether to go for that or not :)

Bye