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

Espanso issue with Visual Studio Code #544

Closed
ramonsmits opened this issue Dec 15, 2020 · 20 comments
Closed

Espanso issue with Visual Studio Code #544

ramonsmits opened this issue Dec 15, 2020 · 20 comments
Labels
bug Something isn't working

Comments

@ramonsmits
Copy link

Replacements do not seem to work well with Visual Studio Code.

2020-12-15_15-47-24

Config:

  - trigger: ":regards"
    replace: "Regards,

Ramon Smits

Solution Architect at Particular Software"
@federico-terzi
Copy link
Collaborator

federico-terzi commented Dec 15, 2020

Hey @ramonsmits,

Thank you for the feedback! What OS are you using?
The force_clipboard option might help you in this case:

  - trigger: ":regards"
    force_clipboard: true
    replace: |
       Regards,
       Ramon Smits
       Solution Architect at Particular Software

Cheers :)

@federico-terzi federico-terzi added the bug Something isn't working label Dec 15, 2020
@bitboxer
Copy link

I have the same issue with VS Code on Mac OS 11.1. Looks like VS Code does something weird with the input, hm?

@federico-terzi
Copy link
Collaborator

@bitboxer yes, VS Code is probably doing a lot under the hoods. As far as my experimentation goes, the clipboard approach is the only robust one at this point

@bitboxer
Copy link

bitboxer commented Feb 2, 2021

@federico-terzi can you make the clipboard way the default if you detect a vscode window? Adding the config to all replacements might look like overkill to me right now.

@federico-terzi
Copy link
Collaborator

@bitboxer Yes, you can setup an app specific configuration for VS Code, including also this line:

backend: Clipboard

Cheers :)

@ramonsmits
Copy link
Author

I tried this:

vscode.yml:

filter_title: "Visual Studio Code"

backend: Clipboard

That, unfortunately, doesn't work.

@federico-terzi
Copy link
Collaborator

@ramonsmits That's unfortunate! Most likely, that's due to a small misconfiguration. A couple of questions:

  1. Did you place the vscode.yml file within the user/ directory? (it's in the same folder as the default.yml file)
  2. Filtering by the title is not always a good choice, as sometimes VS Code does not include "Visual Studio Code" in the title. My suggestion would be to try filtering by the executable name, you can find a small guide here

Cheers :)

@federico-terzi
Copy link
Collaborator

federico-terzi commented Feb 3, 2021

I'm also working on a refactor to automatically include a patch when appropriate, though it will take a while

@ramonsmits
Copy link
Author

ramonsmits commented Feb 3, 2021

@federico-terzi I first had it in ~\AppData\Roaming\espanso but moving it to ~\AppData\Roaming\espanso\user has the same issue.

ok, now I have:

~\AppData\Roaming\espanso\user\vscode.yml

filter_exec : Code.exe
backend: Clipboard

The above is everything I have in that file. This is not working.

@federico-terzi
Copy link
Collaborator

@federico-terzi I'm sorry about that! I've tested the previous configuration and it's working for me. Perhaps, we need to slow down the backspace injection a bit. Could you please try changing the vscode.yml file as:

name: vscode
filter_exec: "Code.exe"
backend: Clipboard
backspace_delay: 10

Also trying to experiment with the value of backspace_delay, increasing it if necessary. The lower the value, the more responsive the expansion will be

Let me know if that helps!

@ramonsmits
Copy link
Author

@federico-terzi That sort of works, the value 10 is too low. Setting it to 12 seems to be the lowest.

FYI, my current config

name: vscode
filter_exec: "Code.exe"
backend: Clipboard
backspace_delay: 12

@bitboxer
Copy link

bitboxer commented Feb 4, 2021

Can confirm, 12 is also working for me on my mac. Thanks for the fast reaction here ❤️

@federico-terzi
Copy link
Collaborator

@ramonsmits @ramonsmits Thank you guys! I'll make sure to include this patch automatically as part of #310

@jaklan
Copy link

jaklan commented May 15, 2021

@federico-terzi unfortunately I still cannot make esperanso work with VSCode on MacOS.

My config looks like:

name: vscode
filter_title: VSCode
backend: Clipboard
backspace_delay: 12

matches:
  - trigger: ":sth"
    replace: "random string"

and when I type in :sth I get: :srandom strin. It obviously seems like some issue with backspace_delay, but I tried multiple values: 0, 10, 12, 100, even 300000 etc., but the result is exactly the same. I also tried to use default backend and play with the delay - also no success, each time there were some strange artefacts.

I use Vim mode in VSCode, but after turning it off there were also similar issues (the output could be a slightly different though).

@federico-terzi
Copy link
Collaborator

Hey @jaklan,

Thank you for experimenting with that solution! If having very high values of backspace_delay doesn't make any difference, there is a good chance espanso did not detect the patch correctly. Please try changing the filter as:

name: vscode
filter_exec: "Visual Studio Code"
backend: Clipboard
backspace_delay: 12

matches:
  - trigger: ":sth"
    replace: "random string"

If even this one does not work, you might need to find a good filter following this section (under "Finding the right filters"): https://espanso.org/docs/configuration/#application-specific-configurations

Cheers :)

@jaklan
Copy link

jaklan commented May 15, 2021

@federico-terzi I can experiment with that a bit more, but in general - the filter seems to work, because the :sth trigger was defined only in this VSCode-specific yaml. So if the trigger is discovered I guess the path is not a problem.

@federico-terzi
Copy link
Collaborator

because the :sth trigger was defined only in this VSCode-specific yaml

I see, yes, filters might be working correctly then...

@doctorboyMP
Copy link

I would like to highlight that I also have this issue, on MacOS 11.3.1, using VSCodium.
Below my configuration:

filter_exec: "VSCodium.app"
backend: Clipboard
backspace_delay: 30000

matches:
  - trigger: ":sth"
    replace: "random string"

The behaviour is erratic; when typing ":sth" sometimes I get the correct strings other times not really. I've played a bit with filter_title as well, without major changes. I've tried backend "Inject", and it got worst.
Any further suggestions? This completely destroys the UX when using vscode.

I really appreciate any help anyone can provide.

@federico-terzi
Copy link
Collaborator

@doctorboyMP @jaklan Thank you guys, I've moved it to a separate discussion: #675

@ibehnam
Copy link

ibehnam commented Jun 28, 2022

I have this issue and none of the solutions worked for me. My config files are synced (on G Drive) and Espanso reads the base config file correctly. But I also created a vscode.yml config file as follows:

filter_title: 'Code'
enable: true
force_clipboard: true

matches:
  - trigger: ":t"
    replace: "Works only on vscode!"

Tried using different identifiers such as filter_title: 'Visual Studio Code' (with and without quotation marks), but Espanso doesn't read the file at all.

I followed your advice to type #detect# in VSCode and got this:

title: 'vscode.yml'
exec: '/Applications/Visual Studio Code.app'
class: 'com.microsoft.VSCode'

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

No branches or pull requests

6 participants