ITADN

Inconsistent Link Creation for Multi-Line Selections (Visual and Operator Modes)

#414ClosedVimWei 创建于 2025-07-05
V
VimWeicommented
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:** 1. **Using Visual Mode (e.g., `V` to 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. ``` 2. **Using Operator Mode (e.g., `gl5w` from "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: 1. **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."). 2. **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.
关闭于 2025-07-21 8 条评论