Skip to content

FinalTerm escape sequences are stripped from prompt filter #457

@krzysdz

Description

@krzysdz

I'm trying to add shell integration using FinalTerm escape sequences following the OSC 133 ; <something> ST format, but all these sequences from filter are removed before printing to the terminal.

ecma48_code::decode_osc decodes these sequences as { .command = '1', .subcommand = '0', .visible = false } and all !visible OSC codes with the command property between 0 and 2 (inclusive) are treated as set console title commands and skipped from the output:

if (osc.visible)
{
if (out)
out->concat(osc.output.c_str(), osc.output.length());
if (cell_count)
cells += clink_wcwidth(osc.output.c_str(), osc.output.length());
}
else if (!apply_title)
goto concat_verbatim;
else if (osc.command >= '0' && osc.command <= '2')
set_console_title(osc.param.c_str());
else

A simple example that demonstrates the problem:

local p = clink.promptfilter(10)
function p:filter(prompt)
    -- OSC 133 sequences from prompt filter are removed before writing to the terminal
    return "\001\x1b]133;D;"..os.geterrorlevel().."\007\002\001\x1b]133;A\007\002"..prompt.." \001\x1b]133;B\007\002"
end

local function command_executed_mark(input)
    -- this works
    clink.print("\001\x1b]133;C\007\002", NONL)
end

clink.onendedit(command_executed_mark)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions