Sublime Forum

Substitiution Snippet with no other text crashes ST3

#1

I’ve got this snippet below:

<snippet> <content><![CDATA[ ${1/^(\w)|(?: (\w))/(?1\l$1:)(?2_\l$2:)/g} ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>jsvar</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <scope>source.js</scope> <description>Javascript snake_case</description> </snippet>
Triggering the above snippet crashes ST3 build 3083 (portable version), results with the following dump file message:

Dump Summary
------------
Dump File:	1b48953b-6f56-4ed3-bf4e-bd203ddd68cd.dmp : ...]\1b48953b-6f56-4ed3-bf4e-bd203ddd68cd.dmp
Last Write Time:	9/29/2015 9:32:52 AM
Process Name:	sublime_text.exe : ...]\sublime_text.exe
Process Architecture:	x64
Exception Code:	0xC0000005
Exception Information:	The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Heap Information:	Not Present

A colleague of mine was able to replicate the crash with the above snippet. Am I doing something wrong with the snippet?

0 Likes

#2

Yes, you can not apply a regular expression onto a field that has no value. And you can’t ask for an input value and apply a regular expression replacement onto it at the same time.

The crash is an unwanted side effect. github.com/SublimeTextIssues/Core/issues/58

0 Likes

#3

Thanks for the response!

For this scenario, what would be a good workaround? I still want to create a simple snippet with regex substitution, but not have duplicates (as in the example in Sublime docs). I don’t think I can have a default and regex right?

0 Likes

#4

[quote=“e.mombay”]Thanks for the response!

For this scenario, what would be a good workaround? I still want to create a simple snippet with regex substitution, but not have duplicates (as in the example in Sublime docs). I don’t think I can have a default and regex right?[/quote]

Well, you could first type the content, then select it and bind a snippet that uses $TM_SELECTION to a keybinding. Other than that, I don’t really see an option because you can not instantly modify what you are typing (it conflicts with the WhatYouTypeIsWhatYouGet principle, if that exists).

0 Likes