-
Notifications
You must be signed in to change notification settings - Fork 66
Inconsistent Link Creation for Multi-Line Selections (Visual and Operator Modes) #414
Description
When attempting to create a wiki link from a selection that spans multiple lines, the behavior of wiki.vim is inconsistent and produces unexpected results, leading to confusion. This occurs in both visual mode and operator-pending mode.
Consider the following example text:
One This is a book about dragon.
Two This is a book about dragon.
Observed Behavior:
- Using Visual Mode (e.g.,
Vto select multiple lines, then<CR>):
One This is a book [about dragon.^@Two This](about-dragon-^@two-this.md) is a book about dragon.
Two This is a book about dragon.
- Using Operator Mode (e.g.,
gl5wfrom "about" on the first line, spanning into the second line):
One This is a book about dragon.
Two This is a book [about dragon.^@Two This](about-dragon-^@two-this.md) is a book about dragon.
These results significantly deviate from expectations and cause considerable confusion. Specifically, we've observed issues such as malformed links and the appearance of unexpected characters (e.g., ^@).
Expected Behavior:
We propose two possible solutions for handling multi-line selections during link creation. Either of these would be acceptable, and you can choose based on your preference and design principles:
-
Ignore and Warn:
If a selection spans multiple lines, the link creation operation is ignored, and a warning message is displayed (e.g., "Cannot create a link from a multi-line selection."). -
Merge and Create:
If a selection spans multiple lines, the content of all selected lines is automatically merged into a single string (e.g., by trimming each line and joining them). A single link is then created from this combined content, replacing the entire multi-line selection.
One This is a book [about dragon. Two This](about-dragon-two-this.md) is a book about dragon.
We believe addressing this inconsistency would greatly improve the user experience for wiki.vim.
Thank you for your consideration.