Skip to content

Commit e818daf

Browse files
Fix scrollbar marks not appearing until scroll or resize (#19185)
This PR resolves an issue where scrollbar marks created by shell integration sequences (OSC 133 FTCS, OSC 1337 iTerm2, and OSC 9;12 ConEmu sequences) were not visible on the scrollbar until the user manually scrolled. The problem was that while marks were being created in the buffer correctly, the UI wasn't being notified to refresh the scrollbar display. The fix adds a new NotifyShellIntegrationMark() method to the ITerminalApi interface that calls _NotifyScrollEvent() to trigger scrollbar refresh, and updates all shell integration sequence handlers in AdaptDispatch to call this notification method after creating marks. This ensures scrollbar marks appear immediately when shell integration sequences are processed, bringing feature parity between auto-detected and shell-integration-based marks. Closes #19104
1 parent 0c3002c commit e818daf

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed

src/cascadia/TerminalCore/Terminal.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class Microsoft::Terminal::Core::Terminal final :
156156
bool IsVtInputEnabled() const noexcept override;
157157
void NotifyAccessibilityChange(const til::rect& changedRect) noexcept override;
158158
void NotifyBufferRotation(const int delta) override;
159+
void NotifyShellIntegrationMark() override;
159160

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

src/cascadia/TerminalCore/TerminalApi.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,9 @@ void Terminal::NotifyBufferRotation(const int delta)
404404
_NotifyScrollEvent();
405405
}
406406
}
407+
408+
void Terminal::NotifyShellIntegrationMark()
409+
{
410+
// Notify the scrollbar that marks have been added so it can refresh the mark indicators
411+
_NotifyScrollEvent();
412+
}

src/host/outputStream.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ void ConhostInternalGetSet::NotifyBufferRotation(const int delta)
446446
}
447447
}
448448

449+
void ConhostInternalGetSet::NotifyShellIntegrationMark()
450+
{
451+
// Not implemented for conhost - shell integration marks are a Terminal app feature.
452+
}
453+
449454
void ConhostInternalGetSet::InvokeCompletions(std::wstring_view /*menuJson*/, unsigned int /*replaceLength*/)
450455
{
451456
// Not implemented for conhost.

src/host/outputStream.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ConhostInternalGetSet final : public Microsoft::Console::VirtualTerminal::
6767

6868
void NotifyAccessibilityChange(const til::rect& changedRect) override;
6969
void NotifyBufferRotation(const int delta) override;
70+
void NotifyShellIntegrationMark() override;
7071

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

src/terminal/adapter/ITerminalApi.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft::Console::VirtualTerminal
8686

8787
virtual void NotifyAccessibilityChange(const til::rect& changedRect) = 0;
8888
virtual void NotifyBufferRotation(const int delta) = 0;
89+
virtual void NotifyShellIntegrationMark() = 0;
8990

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

src/terminal/adapter/adaptDispatch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,6 +3600,7 @@ void AdaptDispatch::DoConEmuAction(const std::wstring_view string)
36003600
else if (subParam == 12)
36013601
{
36023602
_pages.ActivePage().Buffer().StartCommand();
3603+
_api.NotifyShellIntegrationMark();
36033604
}
36043605
}
36053606

@@ -3630,6 +3631,7 @@ void AdaptDispatch::DoITerm2Action(const std::wstring_view string)
36303631
if (action == L"SetMark")
36313632
{
36323633
_pages.ActivePage().Buffer().StartPrompt();
3634+
_api.NotifyShellIntegrationMark();
36333635
}
36343636
}
36353637

@@ -3663,16 +3665,19 @@ void AdaptDispatch::DoFinalTermAction(const std::wstring_view string)
36633665
case L'A': // FTCS_PROMPT
36643666
{
36653667
_pages.ActivePage().Buffer().StartPrompt();
3668+
_api.NotifyShellIntegrationMark();
36663669
break;
36673670
}
36683671
case L'B': // FTCS_COMMAND_START
36693672
{
36703673
_pages.ActivePage().Buffer().StartCommand();
3674+
_api.NotifyShellIntegrationMark();
36713675
break;
36723676
}
36733677
case L'C': // FTCS_COMMAND_EXECUTED
36743678
{
36753679
_pages.ActivePage().Buffer().StartOutput();
3680+
_api.NotifyShellIntegrationMark();
36763681
break;
36773682
}
36783683
case L'D': // FTCS_COMMAND_FINISHED
@@ -3693,6 +3698,7 @@ void AdaptDispatch::DoFinalTermAction(const std::wstring_view string)
36933698
}
36943699

36953700
_pages.ActivePage().Buffer().EndCurrentCommand(error);
3701+
_api.NotifyShellIntegrationMark();
36963702

36973703
break;
36983704
}

src/terminal/adapter/ut_adapter/adapterTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ class TestGetSet final : public ITerminalApi
212212
Log::Comment(L"NotifyBufferRotation MOCK called...");
213213
}
214214

215+
void NotifyShellIntegrationMark() override
216+
{
217+
Log::Comment(L"NotifyShellIntegrationMark MOCK called...");
218+
}
219+
215220
void InvokeCompletions(std::wstring_view menuJson, unsigned int replaceLength) override
216221
{
217222
Log::Comment(L"InvokeCompletions MOCK called...");

0 commit comments

Comments
 (0)