Skip to content

feat: Add WhereDepth user preference for stack depth#6261

Open
limakzi wants to merge 1 commit intogap-system:masterfrom
limakzi:6210-add-where-clause
Open

feat: Add WhereDepth user preference for stack depth#6261
limakzi wants to merge 1 commit intogap-system:masterfrom
limakzi:6210-add-where-clause

Conversation

@limakzi
Copy link
Member

@limakzi limakzi commented Mar 10, 2026

Adds a WhereDepth user preference that controls the default number of stack frames shown by Where and WhereWithVars when called without an explicit depth argument (i.e. in the default OnBreak handler).

Previously this was hardcoded to 5.
The default remains 5, so existing behaviour is unchanged.

Fixes #6210

if false then Stabilizer; fi;
^

#
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, its best place.

@limakzi limakzi marked this pull request as ready for review March 10, 2026 11:07
Copilot AI review requested due to automatic review settings March 10, 2026 11:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new core GAP user preference (WhereDepth) to control the default stack depth used by Where / WhereWithVars when called with no explicit argument (notably via the default OnBreak handler), keeping the default behavior at 5.

Changes:

  • Declare new WhereDepth user preference (default 5, non-negative integer).
  • Use UserPreference("WhereDepth") as the default depth in Where and WhereWithVars.
  • Add an installation test that verifies the preference exists and can be changed.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/init.g Declares the new WhereDepth user preference with default/check logic.
lib/error.g Switches Where / WhereWithVars default depth from constant 5 to UserPreference("WhereDepth").
tst/testinstall/error.tst Adds a basic regression test for reading/setting WhereDepth.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 140 to 145
BIND_GLOBAL("WhereWithVars", function(arg)
local depth;
if LEN_LIST(arg) = 0 then
depth := 5;
depth := UserPreference("WhereDepth");
else
depth := arg[1];
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

UserPreference("WhereDepth") can return fail (preference not declared yet) or a non-integer (since SetUserPreference does not enforce the declared check). In both cases, WHERE_INTERNAL/WHERE will error when comparing depth <= 0, potentially breaking error handling (notably during startup, since lib/error.g is read in lib/read1.g before preferences are declared in lib/init.g). Consider falling back to 5 when the preference is fail or not a non-negative integer.

Copilot uses AI. Check for mistakes.
Comment on lines 151 to 156
BIND_GLOBAL("Where", function(arg)
local depth;
if LEN_LIST(arg) = 0 then
depth := 5;
depth := UserPreference("WhereDepth");
else
depth := arg[1];
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Same as above for Where: UserPreference("WhereDepth") may be fail or non-integer (and during early startup may be undeclared), which will cause WHERE_INTERNAL/WHERE to throw when doing integer comparisons. Add a defensive fallback to the previous default (5) if the preference value is not a non-negative integer.

Copilot uses AI. Check for mistakes.
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.

Add a user preference for changing the default limit for Where from 5 to something else

2 participants