Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Ctrl+Drag&Drop (copy) a selection beginning with # creates a bad link #1002

Closed
jbridgy opened this issue Jan 26, 2023 · 5 comments
Closed
Assignees
Labels

Comments

@jbridgy
Copy link

jbridgy commented Jan 26, 2023

MM v2.7.14 always creates a bad link when you Ctrl+Drag&Drop (copy) a selection that begins with a '#' character.

Creating a correct link (as with Ctrl+K dialog) would be very welcome if the selection is an entire header line,
otherwise the selection should be copied normally.

When a link is created then the selection without leading '#' and ' ' characters and without end of line should be used as Link Text.

EXAMPLE:

MM created the following link when the selection contained the text above beginning with "'#' character":

[' character.

Creating a correct link (as with Ctrl+K dialog) would be very welcome if the selection is an entire header line,
otherwise the selection should be copied normally.

When a link is created then the selection without leading '#' and ' ' characters and without end of line should be used as `Link Text`.
](#' character.

Creating a correct link (as with Ctrl+K dialog) would be very welcome if the selection is an entire header line,
otherwise the selection should be copied normally.

When a link is created then the selection without leading '#' and ' ' characters and without end of line should be used as `Link Text`.
)
@RickStrahl
Copy link
Owner

RickStrahl commented Jan 31, 2023

Do you mean editor to editor selection drag and drop?

Can you post the text you're dragging? I assume the above is the result of the drop?

If it's the actual editor Drag and Drop you are referring to then that falls into ACE Editor code that probably needs to be reported to ACE Editor.

@jbridgy
Copy link
Author

jbridgy commented Jan 31, 2023

Do you mean editor to editor selection drag and drop?

I mean primarily Ctrl+Drag&Drop a selection beginning with a # character within the main editor of MM. However you get the very same result when the selection comes from another editor or a web page.

Can you post the text you're dragging? I assume the above is the result of the drop?

It is already there. The beginning of my initial post is used as source of the drag. Here it is again as proper Markdown text (which is in this case almost identical to the rendered text):

MM v2.7.14 always creates a bad link when you Ctrl+Drag&Drop (copy) a selection that begins with a '#' character.

Creating a correct link (as with Ctrl+K dialog) would be very welcome if the selection is an entire header line,
otherwise the selection should be copied normally.

When a link is created then the selection without leading '#' and ' ' characters and without end of line should be used as `Link Text`.

The selection started with the # character immediately after MM v2.7.14 always creates a bad link when you Ctrl+Drag&Drop (copy) a selection that begins with a '.

@jbridgy jbridgy changed the title Bug: Ctrl+Drag&Drop (copy) a selection beginning with '#' creates a bad link Bug: Ctrl+Drag&Drop (copy) a selection beginning with # creates a bad link Jan 31, 2023
@RickStrahl
Copy link
Owner

You posted what got pasted not what was dragged.

@jbridgy
Copy link
Author

jbridgy commented Feb 1, 2023

Are you joking? Already the title gives enough information to reproduce the bug. The rest just elaborates on that and uses the post itself as an example (kind of recursive).

Here is another example:

  1. Create a new "untitled" document in MM with the following text:
Bug: Ctrl+Drag&Drop (copy) a selection beginning with # creates a bad link
Another non-empty line to demonstrate the bug more obviously.

Drop here:

Last non-empty line.
  1. Select a part of the "untitled" document as shown in the following screenshot:
    image

  2. Ctrl+Drag&Drop the selection to the end of Drop here:. The result will be:

Bug: Ctrl+Drag&Drop (copy) a selection beginning with # creates a bad link
Another non-empty line to demonstrate the bug more obviously.

Drop here:[ creates a bad link
Another non-empty line to demonstrate the bug more obviously.](# creates a bad link
Another non-empty line to demonstrate the bug more obviously.)

Last non-empty line.

Don't forget the suggestion embedded in the initial post which reads:

  1. Creating a correct link (as with Ctrl+K dialog) would be very welcome if the selection is an entire header line,
    otherwise the selection should be copied normally.
  2. When a link is created then the selection without leading # and (space) characters and without end of line should be used as Link Text (first part enclosed in [backets]).

Example:
image

Ctrl+Drag&Drop the selected header line to the end of See also: should result in the following:
image

This result can be achieved already with the Ctrl+K dialog using the # button but less efficiently:
image

@RickStrahl
Copy link
Owner

The issue here is that when the link comes in there's no way to tell about context. The logic that happens here handles all document drop operations (coming from the WebBrowser interface) so it handles editor text drops as well as file drops and other things like bookmark link drops. Additionally the editor handles the drag and drop operation based on the key combos (ie. move by default, copy for ctrl-drag) which accounts for the original text being deleted or staying behind. There's not a lot of wiggle room to provide custom behavior here.

The link expansion was added initially for the bookmark drag feature that allows dragging bookmarks into the document. Luckily those bookmarks come in a specific format (ie.#hash|linkText so I can at least differentiate that).

So, the best solution for this to simply not handle #hash drags specially and handle the specific case of the bookmark drops for link expansion. I've made the change, so now when you drag text that starts with # it just moves/copies the text without any special treatment.

This is also inline with initial intent which never meant to auto-expand links in the first place.

It'll be in 2.8.3.1

@RickStrahl RickStrahl self-assigned this Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants