Use document index to infer a name for a newly created client-side class or routine#1718
Open
isc-bsaviano wants to merge 1 commit intointersystems-community:masterfrom
Open
Use document index to infer a name for a newly created client-side class or routine#1718isc-bsaviano wants to merge 1 commit intointersystems-community:masterfrom
isc-bsaviano wants to merge 1 commit intointersystems-community:masterfrom
Conversation
isc-klu
reviewed
Feb 18, 2026
| // Make sure the file extension is lowercased in the path before matching | ||
| const startOfDocName = (docUri.path.slice(0, -3) + docUri.path.slice(-3).toLowerCase()).lastIndexOf( | ||
| docNamePath | ||
| ); |
Collaborator
There was a problem hiding this comment.
It looks like docNamePath and startOfDocName don’t depend on the outer loop (L457). Since their values stay the same for all i, recomputing them each time adds unnecessary work and makes the logic a bit harder to follow.
It might be clearer—and more efficient—to compute all of the “leading path segments that don’t contribute to the document name” once up front (and possibly cache that across inferDocName calls if it makes sense).
With that in place, the structure of the function could look something like:
export function inferDocName(uri: vscode.Uri): string | undefined {
// check ext
...
// compute "leadings"
const leadings = new Set(index.uris.map(leading))
// find the first leading
for (const leading of leadings) {
if uri.path.startsWith(leading) {
return result = uri.path.slice(leading.length).replaceAll("/", ".") + fileExt;
}
}
}
function leading(docUri: vscode.URI): string {
...
}
Contributor
Author
There was a problem hiding this comment.
Good suggestion KC!
isc-klu
requested changes
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #1715 by implementing a new mechanism for inferring the name of a newly created client-side class or routine. The previous mechanism used the
objectscript.exportsettings and was buggy, so I removed it. However, feedback from some users has indicated that this feature was really helpful. This is my attempt to bring it back in a more reliable way.