Skip to content

Fix/scrollbar marks shell integration #19185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class Microsoft::Terminal::Core::Terminal final :
bool IsVtInputEnabled() const noexcept override;
void NotifyAccessibilityChange(const til::rect& changedRect) noexcept override;
void NotifyBufferRotation(const int delta) override;
void NotifyShellIntegrationMark() override;

void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;

Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,9 @@ void Terminal::NotifyBufferRotation(const int delta)
_NotifyScrollEvent();
}
}

void Terminal::NotifyShellIntegrationMark()
{
// Notify the scrollbar that marks have been added so it can refresh the mark indicators
_NotifyScrollEvent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(To the terminal team:) The synchronous coupling of the output thread --> buffer --> control is a continuously increasing issue IMO. Not just from a perf. standpoint where these callbacks trigger logic while holding the global lock, but also due to us having to painstakingly add logic like this. = Development and runtime overhead. It should be tackled as a proper task in the near-term IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heard. would love to do something about it - without stopping to rewrite the world :)

}
5 changes: 5 additions & 0 deletions src/host/outputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ void ConhostInternalGetSet::NotifyBufferRotation(const int delta)
}
}

void ConhostInternalGetSet::NotifyShellIntegrationMark()
{
// Not implemented for conhost - shell integration marks are a Terminal app feature.
}

void ConhostInternalGetSet::InvokeCompletions(std::wstring_view /*menuJson*/, unsigned int /*replaceLength*/)
{
// Not implemented for conhost.
Expand Down
1 change: 1 addition & 0 deletions src/host/outputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ConhostInternalGetSet final : public Microsoft::Console::VirtualTerminal::

void NotifyAccessibilityChange(const til::rect& changedRect) override;
void NotifyBufferRotation(const int delta) override;
void NotifyShellIntegrationMark() override;

void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override;

Expand Down
1 change: 1 addition & 0 deletions src/terminal/adapter/ITerminalApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace Microsoft::Console::VirtualTerminal

virtual void NotifyAccessibilityChange(const til::rect& changedRect) = 0;
virtual void NotifyBufferRotation(const int delta) = 0;
virtual void NotifyShellIntegrationMark() = 0;

virtual void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) = 0;

Expand Down
6 changes: 6 additions & 0 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3600,6 +3600,7 @@ void AdaptDispatch::DoConEmuAction(const std::wstring_view string)
else if (subParam == 12)
{
_pages.ActivePage().Buffer().StartCommand();
_api.NotifyShellIntegrationMark();
}
}

Expand Down Expand Up @@ -3630,6 +3631,7 @@ void AdaptDispatch::DoITerm2Action(const std::wstring_view string)
if (action == L"SetMark")
{
_pages.ActivePage().Buffer().StartPrompt();
_api.NotifyShellIntegrationMark();
}
}

Expand Down Expand Up @@ -3663,16 +3665,19 @@ void AdaptDispatch::DoFinalTermAction(const std::wstring_view string)
case L'A': // FTCS_PROMPT
{
_pages.ActivePage().Buffer().StartPrompt();
_api.NotifyShellIntegrationMark();
break;
}
case L'B': // FTCS_COMMAND_START
{
_pages.ActivePage().Buffer().StartCommand();
_api.NotifyShellIntegrationMark();
break;
}
case L'C': // FTCS_COMMAND_EXECUTED
{
_pages.ActivePage().Buffer().StartOutput();
_api.NotifyShellIntegrationMark();
break;
}
case L'D': // FTCS_COMMAND_FINISHED
Expand All @@ -3693,6 +3698,7 @@ void AdaptDispatch::DoFinalTermAction(const std::wstring_view string)
}

_pages.ActivePage().Buffer().EndCurrentCommand(error);
_api.NotifyShellIntegrationMark();

break;
}
Expand Down
5 changes: 5 additions & 0 deletions src/terminal/adapter/ut_adapter/adapterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ class TestGetSet final : public ITerminalApi
Log::Comment(L"NotifyBufferRotation MOCK called...");
}

void NotifyShellIntegrationMark() override
{
Log::Comment(L"NotifyShellIntegrationMark MOCK called...");
}

void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override
{
Log::Comment(L"InvokeCompletions MOCK called...");
Expand Down