Open pauljacobson opened 6 years ago
Thank you for this really detailed bug report.
Could you please describe how Alfred.app works? Expanding on tab
key? (I'm not a Mac user so not familiar with those tools)
@neilsustc I'm not sure about the mechanics of the app, I'm afraid. What I can tell you is the process from my perspective:
,ymd
,ymd
produces this: 2018-06-09
(the current date).It may be possible to use the TAB
key as a trigger. I've just configured my app to replace the trigger with the text snippet as soon as I type it.
This is system-wide. I can use it on the command line, in browser text fields, text editors, etc. Basically wherever there is a text field on my laptop. Here is some more information about Alfred, specifically, from a user perspective: Snippets and Text Expansion - Alfred Help and Support.
Thanks for the information. It seems that Alfred.app listens to the typing events and does auto-replacement.
But I really have no idea about how this extension conflicts with it š. One suspected reason might be performance issue caused by this extension, e.g. #181. I'm not sure but let's wait to see whether this will be also resolved by #181.
@neilsustc Thanks for the feedback, and for being so responsive!
I just tested text expansion using TextExpander (another text expansion app for macOS and Windows), and I don't see the same issue with that app. It looks like there may be something about how Alfred interacts with VS Code, and Markdown All in One, that causes the issue I reported.
I've asked for some insights into how Alfred interacts with editors over at the Alfred forum, in case the team there has any they can share: Text expansion issue when working in VS Code - Discussion & Help - Alfred App Community Forum.
Will keep an eye on it
Hi there, Not sure if this will help you https://stackoverflow.com/questions/51249651/cant-expand-alfred-3-snippets-at-integrated-terminal-within-visual-studio-cod/51271241
Try playing around with the settings in Alfred "Auto Expansion Options" in the Snippets section menu. Seems like it's quite buggy. After setting the delay shorter it "sometimes" works by expanding fully but other times the simulated keys still stay there.
@wayne-huang-14 Thanks. To my understanding, the original post suggests setting a longer delay, right?
It doesn't work well as expected tho because if you don't hit the keys in the exact delay it won't auto expand the snippet and in the correct way. So this isn't really a good fix. I've used the snippet feature in many apps and I found only VSCode hinders its use.
Thanks for the input, @wayne-huang-14. I'm using Alfred text expansion in Atom and it worked just fine. It works fine in VS Code with the Markdown All in One extension disabled.
@neilsustc Is there something about how your extension loads, or watches typed text that could be clashing with the text expansion?
hmmm I'm using the Vim plugin and it turns out if I disable it then the snippet expansion would work.
The same thing that this extension and Vim extension both do is listening to some certain key pressing and then do some text editing.
This extension override these keys (enter
, tab
, backspace
etc.)
It does nothing with ASCII characters, so it is wired why this issue happens
I've created a bug in the Vim plugin for anyone that wants to follow it: https://github.com/VSCodeVim/Vim/issues/2845
I have the same problem with AutoHotKey and Markdown All in One. It recently started to be an issue. In non .md files, my text expand correctly. However, it does not in .md files. Maybe this is caused by an update of VS Code, Markdown all in One, or AutoHotKey?
@jflheureux This seems to have more to do with VS Code itself, although I have no idea how.
I have the same problem with AutoHotKey and Markdown All in One. It recently started to be an issue. In non .md files, my text expand correctly. However, it does not in .md files. Maybe this is caused by an update of VS Code, Markdown all in One, or AutoHotKey?
Yes, I have the same issue. markdown all in one is a great ext. But it doesn't let me expand my AHK snippets. Using it on windows 10 and autohotkey.com. For example, this snippet:
::dxt::DevExtreme
So when I type "dxt", it'll expand to "DevExtreme". However, I get this with the extension enabled:
"dxDevExtrem"
Just checked VSCode and VSCodeVim repo and Alfred forum but none of them has any update. It is hard to tell what is the root cause.
Thanks for checking.
Copied from VSCodeVim/Vim#2845
I have also experienced this issue, and was successfully able to work around it by opening Alfred Preferences > Snippets > Auto Expansion Options > Tweaking and setting
Simulated key event speed
to 4/5 (the level belowFaster
). Still, would be nice if this was fixed!
For AutoHotKey users, you can try if there is any similar "speed" option.
Thanks, I'm trying AHK's SetKeyDelay without luck but I'll dig into it some more.
Ok, for AutoHotkey Hotstrings, this works:
:SE, K1:dx::DevExpress
One millisecond delay but it does the job.
From here: https://autohotkey.com/board/topic/63377-delay-in-hotstring/
I have a lot of hotstrings so I likely may not use it since I can live w/o MarkDownAllInOne Ext. But hopefully it helps others.
Another Authotkey user here! š
On my machine, Mehul's solution with the 1ms delay takes noticeably longer to actually insert some text. I found the following solution which inserts it in a less "chunky" manner. Adjust the 1ms till it works for your setup :)
; This worked
::dx::{Sleep 1}DevExpress
; For longer hotstrings, I needed more
::azerty::{Sleep 60}DevExpress
With 250ms pretty much any length of hotstring expanded correctly. I answered this Stackoverflow question with details from this issue.
The same bug might have been present in an earlier version of VSCode: https://github.com/microsoft/vscode/issues/1934
They make mention of this commit fixing it. Unfortunately it's a rather large commit :( https://github.com/microsoft/vscode/commit/a1bd50f63fd8185a13495ff3d4c67396109e4e71 Commit msg: "Fixes #1168: Read synchronously from textarea"
The problem has to do with the backspace
remapping.
Take the following autohotkey hotstring:
::tada::š
This will make typing "tada" followed by one of the "EndingChars" (space, tab, comma, dot, ...) expand to the š emoji.
What you see visually happening on the screen is that Autohotkey does this by first sending a backspace
to the editor 4 times (length of hotstring "tada") and then inserts the replacement text (š)
What happens when this (pretty fantastic) extension is active is that the first x characters get deleted then the replacement text gets inserted and then the remaining (hotstring length - x) characters get deleted. But because the cursor is now at the end of the replacement text... which gets chewed on š
I'll have to learn how to debug the IDE itself or always add a {Sleep 250}
to my hotstrings...
@Laoujin Thanks for sharing! It is really helpful. We have several workarounds now.
I guess this issue can be resolved if we make onBackspaceKey
hook fast enough. But I doubt whether that fast can be practically achieved with current VSCode mechanism. We might need some performance profiles. (need to install a debug version v2.4.0-issue483.zip first)
The commit that fixed this issue in VSCode itself has as message: "Read synchronously from textarea"
Is it possible that backspace does some stuff asynchronously? And if we turn that into synchronous code that the issue is fixed?
Looks reasonable. I can have a try.
@yzhang-gh One of my colleagues suggested a workaround for macOS users who encounter this sort of issue with Alfred.app. They suggested adjusted the text expansion speed in the app, starting with this option in the Snippets section in Alfred Preferences:
Next, adjust the Simulated key event speed to Average or Slow, here:
I had this set to Fastest. When I adjusted the speed to Average, I didn't see the text expansion issue in VS Code with the Markdown All in One extension enabled. I still want to do some more testing, but this adjustment in the Alfred.app settings seems to do the trick.
Tested on:
@pauljacobson Thanks. Looks like the same solution as https://github.com/yzhang-gh/vscode-markdown/issues/200#issuecomment-493770482?
Thanks. Looks like the same solution as #200 (comment)?
Ah, right! Sorry! I finally caught up with you there.
I can confirm that the exact same issue is also present on Windows 8.1 with the Breevy text expander and the Beeftext text expander.
I couldn't get Beeftext to work with Markdown All in One, but there's a workaround for Breevy:
Set "Output Method" to "Clipboard" in the preferences. (The default is "Key press simulation".) Now it takes noticeably longer to expand the snippets, though, so I might not use Markdown All in One (I just started using VS Code).
A permanent fix would be wonderful.
Thanks for the information. Actucally, it is more of a VSCode bug as Vim extension also has this issue https://github.com/yzhang-gh/vscode-markdown/issues/200#issuecomment-405346505. So we probably cannot fix it on this side.
I see, thank you.
It seems this might be the corresponding VS Code bug: #51510 It was closed, but not resolved, though.
aText was not mentioned here but it's another text expanding tool that has this issue when Markdown All in One is enabled.
aText was not mentioned here but it's another text expanding tool that has this issue when Markdown All in One is enabled.
Like @chodorowicz, I'm also experiencing the same issue with aText.
ā aText doesn't have any way to adjust the simulated key event speed
.
The same thing that this extension and Vim extension both do is listening to some certain key pressing and then do some text editing.
This extension override these keys (
enter
,tab
,backspace
etc.)It does nothing with ASCII characters, so it is wired why this issue happens
So disabling the keyboard shortcut markdown.extension.onBackspaceKey
does the job for me. It looks like the only place this is used is when backspacing on list markers which I don't mind not having.
The same thing that this extension and Vim extension both do is listening to some certain key pressing and then do some text editing. This extension override these keys (
enter
,tab
,backspace
etc.) neilsustc/vscode-markdown@cdbe304
/src/listEditing.ts#L8-L20 It does nothing with ASCII characters, so it is wired why this issue happensSo disabling the keyboard shortcut
markdown.extension.onBackspaceKey
does the job for me. It looks like the only place this is used is when backspacing on list markers which I don't mind not having.
In case anyone find useful, I'm using https://github.com/espanso/espanso with the trigger :det
for:
<details>
<summary>
$|$
</summary>
</details>
and it wasn't working until I disabled markdown.extension.onEnterKey
as well (disabling markdown.extension.onBackspaceKey
was not enough).
Before:
After:
To disable, on keybindings.json
:
[
...
{
"key": "enter",
"command": "-markdown.extension.onEnterKey",
"when": "editorTextFocus && !editorHasMultipleSelections && !editorReadonly && !suggestWidgetVisible && editorLangId == 'markdown' && vim.mode != 'CommandlineInProgress' && vim.mode != 'EasyMotionInputMode' && vim.mode != 'EasyMotionMode' && vim.mode != 'Normal' && vim.mode != 'Replace' && vim.mode != 'SearchInProgressMode' && vim.mode != 'SurroundInputMode' && vim.mode != 'Visual' && vim.mode != 'VisualBlock' && vim.mode != 'VisualLine'"
},
...
]
Another espanso user here. Changing the backend from inject to clipboard solves my problem.
One can set App-specific configuration to only enable the Clipboard backend when using vscode
@hleiaa I tried the suggestion you made to modify the backend property by:
markdown.extension.onEnterKey
command (with prefix -
) in keybindings.json
(~/.config/Code/User/keybindings.json
)[
...
{
"key": "enter",
"command": "-markdown.extension.onEnterKey",
"when": "...",
},
...
]
~/.config/espanso/config/code.yml
filter_class: code
enabled: true
backend: Clipboard
and didn't work š,
maybe I'm using the wrong value on filter_class
? š¤,
should I use filter_title
?
with which value you make it work?
Workaround
Delete key bindings for the
markdown.extension.onBackspaceKey
command. This effectively removes some of our list editing features.This issue cannot be resolved in foreseeable future due to how input is handled. https://markdown-all-in-one.github.io/docs/guide/compatibility.html
@Lemmingh 2021-07-02
Introduction
I use Alfred.app for text expansion. I noticed that when I try to expand text snippets in VS Code with Markdown All in One enabled, the text snippets fail to expand completely.
Expected behavior
When using Alfred.app to expand text snippets, the text snippets should expand fully. For example, I've configured Alfred.app to expand
,ymd
into the current date, using this format:2018-06-08
.Another example is
lipsum1
that expands into the following:Actual behavior
Instead of expanding these simple snippets correctly, the snippets expand partially, leaving the first character of two of the snippet in place. Here is a demonstration of text expansion with Markdown All in One disabled, and enabled):
Steps to reproduce behavior
I captured the following error logs using VS Code's Developer Tools while testing with the Markdown All in One extension enabled:
https://gist.github.com/pauljacobson/e726698e68d7be5deeb727079fa8cf78
When I tested with Markdown All in One disabled, there were no errors in the Developer Tools console.
System information
OS: macOS 10.13.4 RAM: 16GB 2133 MHz Model: MacBook Pro (15-inch, 2017) VS Code version: 1.24.0 (this issue manifested with previous versions of VS Code)