-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Implement the rest of the FTCS marks #14341
Conversation
|
||
if (_currentPrompt) | ||
{ | ||
OutputStart(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Both branches end up calling OutputStart
at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only got nits. Definitely want resolution on Leonard's comment before approving though (the dangling pointer thing): #14341 (comment)
void Terminal::AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark, | ||
const til::point& start, | ||
const til::point& end) | ||
const til::point& end, | ||
const bool fromUi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that using indices would be better than using .back()
and adding .insert()
.
Rust exposes this problem much more obviously, as you can't "borrow" foreign data easily there without introducing lifetime issues. A common solution is to instead save a numeric index (or similar) of where the data is stored at. In this case you could store a size_t _currentPromptMarkIndex
which stores the index of the mark inside _scrollMarks
, so that you can safely retrieve it from _scrollMarks
at a later time.
It's basically exactly like the _currentPrompt
pointer since it's still sort of a (relative) memory location, but unlike it, it's much easier to prove that it doesn't reference invalid data (by checking that _currentPromptMarkIndex < .size()
). This way you don't need to insert()
user marks at the beginning either, allowing you to remove this boolean parameter. Such a numeric index doesn't fix any "stateful" bugs of course, but it does prevent memory lifetime issues, as was the case with the raw pointer.
@@ -1576,13 +1623,19 @@ void Terminal::ClearMark() | |||
start = til::point{ GetSelectionAnchor() }; | |||
end = til::point{ GetSelectionEnd() }; | |||
} | |||
auto inSelection = [&start, &end](const DispatchTypes::ScrollMark& m) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I just realized that the two positions were for a selection!)
This comment has been minimized.
This comment has been minimized.
// We know that "0" will be successfully parsed, and that's close enough. | ||
unsigned int parsedError = 0; | ||
error = Utils::StringToUint(errorString, parsedError) ? parsedError : | ||
static_cast<unsigned int>(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am moderately horrified about this actually -- why is this better than UINT_MAX
or whatever? Do we really want to use -1
to indicate.. uh, something? But, if we really want -1
shouldn't it be signed?
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
@zadjii-msft how can I play around with this? I'm adding support to oh-my-posh for this, so I would love to validate. I'm already on the correct version (v1.17.1023). |
@JanDeDobbeleer I absolutely need to write a better guide, but in leiu of that,
|
As noted in #11000.
This adds support for
FTCS_COMMAND_START
,FTCS_COMMAND_EXECUTED
andFTCS_COMMAND_FINISHED
, which allow a shell to more clearly markup parts of the buffer.As a trick, I'm also making the
experimental.autoMarkPrompts
setting act like aFTCS_COMMAND_EXECUTED
if it comes after aFTCS_COMMAND_START
. This lets the whole sequence work for cmd.exe (which wouldn't otherwise be possible).My cmd prompt
pwsh profile, heavily cribbed from vscode
Doesn't close any issues, because this was always just an element in megathread: Scrollbar Marks #11000
I work here
From FHL code