Hi All,
I'm getting "not the behaviour I expect" when I have a Smart Selection using `Send text...` action (maybe it's a bug, maybe my expectations are wrong).
Basically, I have a Smart Selection which does a `Send text...` of `\1` which I use to "click to copy" various things. I noticed however that when I used it to copy
echo '\t\n'
it was sent as
echo '\t'
- the \n has been suppressed. A bit of digging later, and I I think it's because of the `computeParameterForActionDict` expansion order, which is called by `contextMenuActionSendText`. Sorry I haven't run it up in the Xcode debugger [thought I'd check it's not intended or unfixable before digging more]. I have a debuglog.txt showing the `\n` has been expanded near there, I think it suppressed later in the text entry.
for (int i = 0; i < 9; i++) {
NSString *repl = @"";
if (i < components.count) {
repl = [self parameterValue:[components objectAtIndex:i]
encodedForAction:action];
}
parameter = [parameter stringByReplacingBackreference:i withString:repl ?: @""];
}
NSString *workingDirectory = [scope path];
NSString *hostname = [scope hostname];
NSString *username = [scope username];
parameter = [parameter stringByReplacingEscapedChar:'d' withString:workingDirectory ?: @"."];
parameter = [parameter stringByReplacingEscapedChar:'h' withString:hostname];
parameter = [parameter stringByReplacingEscapedChar:'u' withString:username];
parameter = [parameter stringByReplacingEscapedChar:'n' withString:@"\n"];
parameter = [parameter stringByReplacingEscapedChar:'\\' withString:@"\\"];
which performs the string escaping of the `Send text...` parameter _after_ expanding the `\1` match group. Naively, I would want it the other way around - the special characters are expanded only when literally present in the format string in the `Parameter` column.
In testing, I see that `\d` for example is also expanded when in the *captured* text.
The "Use interpolated strings for parameters (affects all rules)" checkbox looks attractive, but "affects all rules" is a problem for me (I have other smart selections that use `\d` to run commands in the right place).
Sooooo ....
a) is this considered a bug, and would a patch to switching the order of the blocks above be well received ? If so, would you want it guarded by a "Advanced Settings" flag (I guess it's plausible that people want / are relying on current behaviour?).
b) I guess I could imagine a per rule checkbox managing this behaviour - that'd be more work but if that's the direction you want I'll have a crack.
c) A coarse workaround for me would be a "Send text with limited interpolation..." action, but that feels pretty bespoke and weird ... I guess "Send parameter as text..." might be plausible?
Lmk if you'd rather a bug on gitlab, and I'm happy to whack some code together if you lmk which direction is preferable (I'll just need to get Xcode working properly on my machine again :-) ).
- Robbie
p.s. as always - thanks for iTerm2 - it's :amaze: