Skip to content

feat(gutter): added keyboard handling for experimental feature custom widgets #5796

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 2 commits into from
Apr 15, 2025

Conversation

nlujjawal
Copy link
Contributor

@nlujjawal nlujjawal commented Apr 14, 2025

Description of changes:
Added keyboard handling for experimental feature custom widgets which required changes for the code which handles when gutter is active and user presses enter, up, down, space etc.
Its a followup to this #5787 where in we added experimental ability of replacing the fold widgets with custom widgets.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nlujjawal nlujjawal requested review from akoreman and nightwing and removed request for akoreman April 14, 2025 14:33
Copy link

codecov bot commented Apr 14, 2025

Codecov Report

Attention: Patch coverage is 96.03175% with 5 lines in your changes missing coverage. Please review.

Project coverage is 87.34%. Comparing base (6fde745) to head (35f42a3).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/keyboard/gutter_handler.js 92.75% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5796      +/-   ##
==========================================
+ Coverage   87.32%   87.34%   +0.02%     
==========================================
  Files         605      605              
  Lines       44527    44620      +93     
  Branches     7287     7301      +14     
==========================================
+ Hits        38881    38975      +94     
+ Misses       5646     5645       -1     
Flag Coverage Δ
unittests 87.34% <96.03%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@@ -205,6 +206,7 @@ class GutterKeyboardHandler {
switch (this.activeLane){
case "fold":
this.$blurFoldWidget(this.activeRowIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does $blurFoldWidget here expect there always to be a foldwidget at the provided row or will it handle the possibility of no fold widget being there okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It handles the possibility of no fold widget here.

@@ -265,6 +279,28 @@ class GutterKeyboardHandler {
return null;
}

// Given an index, find the nearest index with a customwidget
$findNearestCustomWidget(index) {
Copy link
Contributor

Choose a reason for hiding this comment

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

bit of a nitpick given that these are all private methods, but given that fold widgets and custom widgets are mutually exclusive (a row can only either have a fold widget or a custom widget), would it make sense to just have a single method findNearestFoldLaneWidget (or something along those lines) to find whatever widget is closest in the fold lane (same for all other methods involving fold and custom widgets)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack.
Merging nearestCustomWidget and nearestFoldWidget makes sense, for other methods it doesn't make much sense as it will increase the lines of code requried.

@nlujjawal nlujjawal requested a review from xyos April 15, 2025 08:37
var i = 0;
while (index - i > 0 || index + i < this.lines.getLength() - 1){
i++;
if (index - i >= 0 && this.editor.session.$customWidgets[this.$rowIndexToRow(index - i)])
Copy link
Contributor

Choose a reason for hiding this comment

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

Why aren't we using isCustomWidgetVisible here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah updated, both things can be same its equally same but for consistency updated that.

@nlujjawal nlujjawal merged commit 8037400 into master Apr 15, 2025
3 checks passed
@nlujjawal nlujjawal deleted the gutter_keyboard branch April 15, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants