xixiaofinland / sf.nvim

22 stars 6 forks source link

Retrieve messing up layouts due to spaces and url encoding #63

Closed FedeAbella closed 1 month ago

FedeAbella commented 1 month ago

Here's something weird: image

Got a custom metadata type called Healthcare.gov Endpoint, now for standard Salesforce API names, this is fine, as every weird thing gets moved to an underscore. But for layouts, for some inconceivable reason, Salesforce decides to keep the spaces, and looks like encoding the .. This makes it so when passing the metada name from telescope to the command, the spaces break up the metadata name parameter, and the % in the escaped dot is expanded by nvim into the full buffer path :rofl:

Maybe we could enclose the whole thing in quotes to avoid the spaces? Not sure how to avoid the expansion of %.

Tbh, I'm kinda swamped with things right now, but this may not be urgent, so if it's still around in a few weeks to a month, I might even try and take a look at solving it.

xixiaofinland commented 1 month ago

All commands to be processed in the integrated terminal are sent to Term.run(c), which uses expandcmd() to expand the entire command string c. Check :h expand to see what special characters are expanded.

Either we split c into chunks and expand only the parts we want to, or you fix it in telescope :). I don't use telescope anymore, why does it alter your file name into %:p %:h ?

FedeAbella commented 1 month ago

Actually, it looks like telescope is passing the correct cmd. This is a print before sending it to T.run: image

Of course, it's missing the quotes to handle spaces, but that's easy enough now that I look at it. The expand though, not sure what the best approach might be

xixiaofinland commented 1 month ago

is your code aligned with my latest? I do already have quoted \'%s:*\'. https://github.com/xixiaofinland/sf.nvim/blob/844c9f01dd08036b9b1cafc9d037152b83ac167b/lua/sf/md.lua#L205

And I can't reproduce your issue in my latest version.

FedeAbella commented 1 month ago

Hey, you're right, I was out of sync with upstream. Love some of the new changes, especially making hotkeys optional and separate from commands! :grin:

I do have the quotes there now, but those are only for pulling all components of a single type. Pulling a single component still has no quotes (but I can make a PR for that, no worries).

As for the issue, here's some steps to reproduce: 1) Create a custom object (custom metadata type is way easier) that has a . in the label 2) Add Layout to the md types to retrieve 3) Attempt to retrieve the layout for the created object.

The . in the label should get encoded to %2E in the layout's name, which when passed to Term, will get expanded to <current buffer>2E in the middle of the layout name

xixiaofinland commented 1 month ago

Thank you for the PR, merged :)!