Skip to content
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

Remove unnecessary catch which caused confusing error when iteration scopes were missing #2740

Merged
merged 1 commit into from
Jan 21, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,13 @@ export class EveryScopeStage implements ModifierStage {
if (scopes == null) {
// If target had no explicit range, or was contained by a single target
// instance, expand to iteration scope before overlapping
try {
scopes = this.getDefaultIterationRange(
scopeHandler,
this.scopeHandlerFactory,
target,
).flatMap((iterationRange) =>
getScopesOverlappingRange(scopeHandler, editor, iterationRange),
);
} catch (error) {
if (!(error instanceof NoContainingScopeError)) {
throw error;
}
scopes = [];
}
scopes = this.getDefaultIterationRange(
scopeHandler,
this.scopeHandlerFactory,
target,
).flatMap((iterationRange) =>
getScopesOverlappingRange(scopeHandler, editor, iterationRange),
);
Comment on lines +76 to +82
Copy link
Member

@phillco phillco Jan 21, 2025

Choose a reason for hiding this comment

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

This basically reverts the logic added in https://github.com/cursorless-dev/cursorless/pull/2081/files#diff-a47f14c27291690e54ca5b2e034c62193e9da0615bdb7b3be4153ede7668914f.

It was necessary when there was this fallback code after it:

    if (scopes.length === 0) {
      if (scopeType.type === "collectionItem") {
        // For `collectionItem`, fall back to generic implementation
        return this.modifierStageFactory
          .getLegacyScopeStage(this.modifier)
          .run(target);
      }

      throw new NoContainingScopeError(scopeType.type);
    }

We have since removed the legacy code but didn't know that this code also needed to be removed

}

if (scopes.length === 0) {
Expand Down
Loading