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
Fix selection after running a settings quick action #2756 #3835
Conversation
1dfdcf0
to
4502b9d
Compare
@felixfbecker this fix is ready for review, when you have some time |
51a19db
to
487c8f3
Compare
4de0a26
to
630fcc9
Compare
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 have to admit I don't have knowledge of how this code works. @sqs could you review this?
monacoEdits[0].range.getStartPosition(), | ||
monacoEdits[monacoEdits.length - 1].range.getEndPosition() | ||
) | ||
const editText = monacoEdits[0].text |
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.
Why is it okay to assume this only has one element?
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.
editText
here is a single bucket, a string consisting of all the new editions contributed to the settings editor by quick configure actions since last save update
. The editions made by multiple quick configure actions (what we are interested in) will all appear together.
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.
So it's guaranteed that monacoEdits
is always just one element? If so please add a comment stating that for future readers
'3', | ||
// selectText for addSlackWebhook: | ||
'YOUR-WORKSPACE-NAME', | ||
] |
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.
So we need to hard code here what the selectText is for each quick action? Why are they not defined where the quick action is defined? It's gonna be really hard to remember you need to do this in two places when adding new quick actions
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.
We are never going to have to hard code the selectText twice. Either you can hard code it in the place where the quick configure action is defined, or you can't because of the leading comma issue. When you can't, I believe you want flexibility to set a selectText after the editions have happened. My solution offers that flexibility.
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.
What I mean is that the value of these strings exist twice in the code base, which means they are at risk of getting out of sync, so it is just a matter of time until they will and it will not be obvious when adding new quick actions. There must be a solution to avoid this
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.
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.
The leading/trailing comma issue is the issue we are addressing right now, @felixfbecker . But it sounds to me that my assumption ☝️ was incorrect. I will try an approach to this bug that is more radical, based on the assumption that a selectText
for a quick configure action must always be specified in advance.
monacoEdits[monacoEdits.length - 1].range.getEndPosition() | ||
) | ||
const editText = monacoEdits[0].text | ||
if (editText) { |
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.
It's touch for me to understand what the intention is in these two branches. Comments would really help here.
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.
Thank you for demanding this. It has made the code significantly better.
630fcc9
to
5ed2ae0
Compare
@felixfbecker, thanks for the feedback. Great points. I tried to respond to them with changes to the fix I am proposing. The code is much better for it. 🙏 |
12645ba
to
dd30bbc
Compare
dd30bbc
to
e57e7fa
Compare
@felixfbecker once you revise the assumption that I began with, the present change fixes the issue, which means the bug basically disappears. All we needed were the missing If there is something I am missing, please advise. Otherwise, here you go. |
@felixfbecker can you take another look at this soon? |
Thanks for the contribution, @b-j-p! You should receive feedback on your pull request within a few days. If you haven't already, please read through the contributing guide, and ensure that you've signed the CLA. Did you run into any issues when creating this PR? Please describe them in an issue so we can make the experience better for the next contributor. |
1 similar comment
Thanks for the contribution, @b-j-p! You should receive feedback on your pull request within a few days. If you haven't already, please read through the contributing guide, and ensure that you've signed the CLA. Did you run into any issues when creating this PR? Please describe them in an issue so we can make the experience better for the next contributor. |
Thanks for the contribution, @b-j-p! You should receive feedback on your pull request within a few days. If you haven't already, please read through the contributing guide, and ensure that you've signed the CLA. Did you run into any issues when creating this PR? Please describe them in an issue so we can make the experience better for the next contributor. |
Fixes #2756
Assumption: there are some quick configure actions for which a
selectText
may be set a priori, and then there are other quick configure actions for which this is not possible.The change that I am proposing offers a handy way to generate
selectText
a posteriori, taking the whole editor into consideration, after all changes have been applied.