Apply Text Factory failure

I have a BBEdit Text Factory that un/comments code in FileMaker custom functions. It was working fine 4 years ago when I last used FileMaker. However, it consistently fails now. I have demonstrated that the Text Factory works inside BBEdit. In Keyboard Maestro I have tried

  • switching between using the System Clipboard and a Named Clipboard
  • reselecting the Text Factory file from the KM action
  • renaming the Text Factory because the original file name had an ellipsis (…) in it

I have manually "Try"ed the Text Factory action, confirming the clipboard contents before and after invoking it, getting no change (no bracketing begin/end comment markers). Also confirmed that %ActionResult% is "OK".

I haven't seen any other postings about problems like this. Has any one else seen this? Should I file a bug report?

Thanks,
Gerrie

I just tried a simple text factory (just Uppercase).

And corresponding action:

image

And it worked without issue:

So nothing seems to have changed with the actions and the behaviour of BBEdit.

I would suggest you try that simple text factory and see if that works, and then if it does, try to figure out what is different about yours and why yours might not be working.

Can't speak for the Text Factory side -- but do you actually need that? If all you are doing is creating or removing comments from some selected text:

FMPro Toggle Block Comments.kmmacros (3.4 KB)

Image

Even a more complicated Factory should be reproducible.

@peternlewis, I did try your example. Same behavior: I get unchanged text back from KM but can demonstrate it does correctly uppercase text in a BBEdit document.

I noticed that you placed your Text Factory directly under "BBEdit/", not "BBEdit/Text Filters/" where BBEdit expects them. BBEdit won't find it there to apply internally, but I did try it there using KM, and still no luck. I also tried booting in Safe Mode to see if anything else I'm running might interfere, but that also made no difference. And, I tried running it on text selection in a comment in the KM action to make sure invoking from FileMaker didn't have anything to do with it. I don't have time to further debug this right now, so I'll probably use @Nige_S's workaround for the moment.

I'm running Sonoma 14.7, KM 11.0.3, BBEdit 15.1.2 on a 16" M1 Pro MBPro (2021).

One last thing, what did you do to create the display of "Hello" "HELLO" that also has the KM icon?

@Nige_S, thanks for putting the effort into this example. I'm aware of and regularly use KM's regex capabilities, but for some more complex ones, I find it easier to construct and debug them in BBEdit. This may just be a personal preference, but it's clearly the workaround I need until I can get them working again from KM. I also use Text Factories for other things that can't be done in KM so easily.

BTW, the your test for whether to comment or uncomment needs to accommodate leading white space, among other things. It is also too aggressive on deletion of comment markers. FileMaker allows nested comments. Yours uncomments nested comments and also removes comment delimiters that appear inside quoted text.

Seems pretty similar to my setup here where it works, so I'm at a loss.

That is just a screenshot from the Clipboard History Switcher showing the two entries to confirm it worked.

It was only a quick demo, based solely on

I have a BBEdit Text Factory that un/comments code in FileMaker custom functions.

Hardly a comprehensive design statement...

It'll be much better to get your existing Text Factory to work rather than replicate it with KM actions. The best way to help people to help you is to post a minimal macro that demonstrates the problem -- since Peter's example also fails, post the macro you used for that.

Instructions on how to post your macro can be found at How to Post/Upload your Macros and Scripts

If the worst comes to the worst you should be able to

  1. Use an action to write your text into a temp file
  2. Use an AppleScript action to tell BBEdit to apply the Text Factory to that file
  3. Use an action to read the file back in

...so KM is doing the job at arm's length.

Here is THE macro, not a minimal example:

Actions (v11.0.3)

Keyboard Maestro Actions.kmactions (2.5 KB)

Keyboard Maestro Export

Here also is a zip file containing the Uppercase Selection.textfactory and screen capture of the text factory from BBEdit.

Uppercase.textfactory.zip (934 Bytes)

You won't want to hear this, but... works fine here.

What I did have to do was give permission for KM to automate BBEdit. Check System Settings->Privacy & Security->Automation and make sure there's an entry for BBEdit in the Keyboard Maestro section and that it is turned on.

And when I turn that permission off the macro runs without error but seemingly does nothing, which would appear to be the behaviour you're seeing.

Not too surprising, given that it also worked for Peter.

It turns out that I did have to (re?)enable this. Who knows what specific security changes Apple has made during my FileMaker usage lapse.

Unfortunately, it still doesn't work for me. I also tried again in Safe Mode, so there are no obvious extra utilities interfering. Maybe it'll magically get fixed when I upgrade to Sequoia.

I did observe some strange behaviors, though.

  • When automate BBEdit is disabled, it still launches.
  • When I run my original un/comment macro, with automation enabled, BBEdit posts a notification that "Text Factory Completed"
  • When I run the uppercase macro, BBEdit does not post a notification

Thanks for all your help, @Nige_S.

I clearly have more debugging work to do. I'll probably start with Bare Bones to see if there's any way to get some debug info out of BBEdit. This will have to wait, though. I'm running out of time on my FileMaker trial period, trying to figure out if I really want to fork over US$356 for upgrades on a recurring basis.

1 Like