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

Text snippets don't expand correctly when using text expansion, with Markdown All in One enabled #200

Open
pauljacobson opened this Issue Jun 8, 2018 · 15 comments

Comments

4 participants
@pauljacobson

pauljacobson commented Jun 8, 2018

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:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

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

  1. I started VS Code with all extensions disabled. My text snippets expanded correctly, so this isn't an issue with VS Code.
  2. I restarted VS Code normally, and tested my snippets again. I was able to reproduce the issue.
  3. I disabled Markdown All in One, attempted the snippets again. This time, the snippets expanded correctly.
  4. I re-enabled Markdown All in One again, the issue returned.

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)

@neilsustc

This comment has been minimized.

Owner

neilsustc commented Jun 9, 2018

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)

@pauljacobson

This comment has been minimized.

pauljacobson commented Jun 9, 2018

@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:

  1. I create a snippet in Alfred. I'll specify three aspects:
  2. The snippet name (more so I can find it)
  3. The snippet trigger (for example ,ymd
  4. The text to be inserted when I activate the trigger.
  5. Alfred then basically listens for the trigger when I type it inline (I can also open a small dialogue and trigger the snippet from there).
  6. When I type the trigger, Alfred replaces that trigger text with the text. In this example, typing ,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.

@neilsustc neilsustc added the bug label Jun 9, 2018

@neilsustc

This comment has been minimized.

Owner

neilsustc commented Jun 9, 2018

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.

@pauljacobson

This comment has been minimized.

pauljacobson commented Jun 9, 2018

@neilsustc Thanks for the feedback, and for being so responsive!

@pauljacobson

This comment has been minimized.

pauljacobson commented Jun 9, 2018

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.

@neilsustc

This comment has been minimized.

Owner

neilsustc commented Jun 9, 2018

Will keep an eye on it

@wayne-huang-14

This comment has been minimized.

wayne-huang-14 commented Jul 12, 2018

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.

@neilsustc

This comment has been minimized.

Owner

neilsustc commented Jul 13, 2018

@wayne-huang-14 Thanks. To my understanding, the original post suggests setting a longer delay, right?

@wayne-huang-14

This comment has been minimized.

wayne-huang-14 commented Jul 13, 2018

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.

@pauljacobson

This comment has been minimized.

pauljacobson commented Jul 14, 2018

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?

@wayne-huang-14

This comment has been minimized.

wayne-huang-14 commented Jul 14, 2018

hmmm I'm using the Vim plugin and it turns out if I disable it then the snippet expansion would work.

@neilsustc

This comment has been minimized.

Owner

neilsustc commented Jul 14, 2018

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.)

commands.registerCommand('markdown.extension.onEnterKey', onEnterKey),
commands.registerCommand('markdown.extension.onCtrlEnterKey', () => { onEnterKey('ctrl'); }),
commands.registerCommand('markdown.extension.onShiftEnterKey', () => { onEnterKey('shift'); }),
commands.registerCommand('markdown.extension.onTabKey', onTabKey),
commands.registerCommand('markdown.extension.onShiftTabKey', () => { onTabKey('shift'); }),
commands.registerCommand('markdown.extension.onBackspaceKey', onBackspaceKey),
commands.registerCommand('markdown.extension.checkTaskList', checkTaskList),
commands.registerCommand('markdown.extension.onMoveLineDown', onMoveLineDown),
commands.registerCommand('markdown.extension.onMoveLineUp', onMoveLineUp),
commands.registerCommand('markdown.extension.onCopyLineDown', onCopyLineDown),
commands.registerCommand('markdown.extension.onCopyLineUp', onCopyLineUp),
commands.registerCommand('markdown.extension.onIndentLines', onIndentLines),
commands.registerCommand('markdown.extension.onOutdentLines', onOutdentLines)

It does nothing with ASCII characters, so it is wired why this issue happens

@wayne-huang-14

This comment has been minimized.

wayne-huang-14 commented Jul 16, 2018

I've created a bug in the Vim plugin for anyone that wants to follow it:
VSCodeVim/Vim#2845

@jflheureux

This comment has been minimized.

jflheureux commented Oct 30, 2018

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?

@pauljacobson

This comment has been minimized.

pauljacobson commented Nov 2, 2018

@jflheureux This seems to have more to do with VS Code itself, although I have no idea how.

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