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

VSCode issue on macOS #675

Open
federico-terzi opened this issue May 22, 2021 · 12 comments
Open

VSCode issue on macOS #675

federico-terzi opened this issue May 22, 2021 · 12 comments
Labels
bug Something isn't working MacOS Related to the MacOS operating system

Comments

@federico-terzi
Copy link
Collaborator

Some users reported problems with VSCode on macOS:

See: #544 (comment) and #544 (comment)

@federico-terzi federico-terzi added bug Something isn't working MacOS Related to the MacOS operating system labels May 22, 2021
@trenaryja
Copy link

trenaryja commented Oct 12, 2021

Additional finding that might be relevant: it seems to be dependent on the Language Mode of the current editor within VSCode.

For Javascript files, the expansions work perfectly, as expected. Same goes for Plaintext. However, when setting the language mode to Markdown (or opening a .md file) the expansions seem to be partially interrupted. As an example, I have this config:

global_vars:
  - name: date
    type: date
    params:
      format: "%F"

matches:
  - trigger: ":date"
    replace: "{{date}}"

When typing :date in a plaintext file, I get the expected result:

2021-10-12

However, when typing in a markdown file, I am left with this result:

:date2021-

Note: It does look like the full expansion flashes on the screen VERY briefly, after the trigger text, but is then truncated to the result above. Also, I have the Markdown All in One extension installed. Uninstalling it seems to fix this behavior but I'm hopeful that there is a way to have my cake and eat it too, and that the potential fix will also help the other users who originally reported this bug.

Thanks for building and maintaining a great tool!

@federico-terzi
Copy link
Collaborator Author

Hey @trenaryja,

Thanks for reporting this issue! Probably, that combination of language+extension is interfering with the way Espanso injects the replacements.
To solve the problem, we would probably need to create a custom VSCode extension that interfaces with Espanso and injects the text into the buffers directly.
I'd love to create something like that in the future, though I don't have any ETA yet :)

In the meanwhile, could you please try with the force_clipboard: true option and see if that helps?

global_vars:
  - name: date
    type: date
    params:
      format: "%F"

matches:
  - trigger: ":date"
    force_clipboard: true
    replace: "{{date}}"

Cheers :)

@trenaryja
Copy link

Hey @federico-terzi!

Thanks for the quick response! Sadly that didn't change the behavior.

Thanks for giving it a shot though! I definitely understand how there's no easy and immediate solution since a VSCode extension could be doing who-knows-what under the hood.

Creating an Espanso extension would be AMAZING though, definitely keeping my fingers crossed for that sometime in the future 😄. In the meantime, I simply trigger the match somewhere else and quick copy-paste it where I need it. Still ultra handy!

@federico-terzi
Copy link
Collaborator Author

@trenaryja Sounds good! Thank you :)

@jknight
Copy link

jknight commented Feb 24, 2022

force_clipboard: true worked for me, thanks :)

MacOS Catalina / Visual Studio Code Version: 1.64.2

@joshsaintjacque
Copy link

joshsaintjacque commented Mar 10, 2022

force_clipboard: true worked for me, thanks :)

That totally worked for me, as well!

Thanks for maintaining a great project.

@swcurran
Copy link

swcurran commented Jun 25, 2022

VSCode is the only place where I can't use espanso effectively, for the problems outlined about -- partial erasure of the trigger and a corresponding partial pasting of the replacement. @trenaryja 's observation about language mode seems to be right -- the language mode (and especially markdown) is my problem (and I write a lot of MD...). Confirmed that in the same setup, writing in a JS file, replacements work perfectly (although small test :-) ). Confirmed as well that force_clipboard doesn't fix it for me. Next plan is to see about what in the MD handler in VSCode might be the issue.

espanso is brilliant -- I have a great setup and it is a huge productivity booster!

@scokobro
Copy link

Couldn't manage without Espanso - many thanks!
Similar issue to others here; erratic/abbreviated expansions writing markdown in VSCode.
Just to report that adding force_clipboard: true to my config file seems to have fixed this for me.
MacOS: Sonoma 14.0
VSCode: Version: 1.82.2

@smeech
Copy link
Collaborator

smeech commented Feb 13, 2024

Is this still a problem, or has it been fixed with backend: or force_mode:/force_clipboard: settings?

@pyxelr
Copy link

pyxelr commented Mar 28, 2024

@smeech: For me, it still seems to have some issues with or without these options (I am on M1 with Ventura 13.6.4 and VS Code 1.87.2).

For example, here is my markdown.yaml:

matches:
  - triggers: [";markdowninfo ", ";minfo "]
    replace: ">ℹ️ _$|$._"
  - triggers: [";markdowntoc ", ";mtoc "] # automatic ToC for GitLab Flavored Markdown
    replace: |
              **Table of Contents**:

              [TOC]

              ---
  - triggers: [";markdownsection ", ";msec "] # collapsible Markdown section
    replace: |
              <details>
              <summary>

              `$|$ 📜`

              </summary>

              XYZ

              </details>

Typing ;mtoc in an .md file may end with:

**Table of Contents**:[TOC]
---

or

**Table of Contents**:[TOC]---

Typing ;msec in a .md file may end with something like this:

;<details><summary` 📜`
</summary>

XYZ

</deta
il

s

>

However, in a .py file it ends up looking the worst:

<details><summary>` 📜`</summary>XYZ</details>

I am guessing that some internal processing of VS Code files (or my Python/Markdown config/plugins) affects all of it.

For now, my typical workaround is to run the trigger in Sublime Text and copy the match from there, or at least run it in a new blank VS Code tab that does not have any selected language mode (like Python or Markdown).

@smeech
Copy link
Collaborator

smeech commented Mar 28, 2024

Thank you - that's helpful in clarifying the problem.

The different behaviour depending on the FileType does tend to suggest the issue is more to do with the way VSCode formats its input, than Espanso per se. If the behaviour is consistent, it may be possible to format the replacement text to do what you want. E.g. you could try quoting the block-scalars to give you more control, with newlines etc..

@smeech
Copy link
Collaborator

smeech commented Apr 7, 2024

Please note, force_clipboard: is now deprecated in favour of the force_mode: clipboard/keys options, which are more flexible.
See #1939.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working MacOS Related to the MacOS operating system
Projects
None yet
Development

No branches or pull requests

8 participants