mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-18 23:59:43 +01:00
De-prioritize markdown link paste in code blocks (#202109)
This commit is contained in:
@@ -111,12 +111,16 @@ export function shouldSmartPaste(document: ITextDocument, selectedRange: vscode.
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: use proper parsing instead of regexes
|
||||
for (const regex of smartPasteRegexes) {
|
||||
const matches = [...document.getText().matchAll(regex.regex)];
|
||||
for (const match of matches) {
|
||||
if (match.index !== undefined) {
|
||||
const useDefaultPaste = selectedRange.start.character > match.index && selectedRange.end.character < match.index + match[0].length;
|
||||
if (useDefaultPaste) {
|
||||
const matchRange = new vscode.Range(
|
||||
document.positionAt(match.index),
|
||||
document.positionAt(match.index + match[0].length)
|
||||
);
|
||||
if (matchRange.intersection(selectedRange)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user