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

粘贴多行代码时,避免代码段的 ``` 与当前行内容混淆在一起 #644

Merged
merged 5 commits into from Jul 29, 2020

Conversation

zTree
Copy link
Contributor

@zTree zTree commented Jul 29, 2020

Issue 现象:
粘贴多行代码时,如果光标在当前行的文字后面,代码段的开头标识 ``` 会与当前行内容混淆在一起,导致代码段解析错误

Issue 影响的模式:即时渲染模式 & 分屏预览模式

例子:
首先输入:1111,让光标在 文字最后,然后去 VSCode 内复制多行代码,进行粘贴

var a = 1;
var b = 2;

两种模式粘贴后显示现象分别如下:

image
image

修正方法:在调用 pasteCode 方法之前,判断 code 如果是多行内容,则在开头增加 "\n",保证 document.execCommand("insertHTML", false, code); 方法正常在当前行的下一行 插入代码区域

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants