-
Notifications
You must be signed in to change notification settings - Fork 107
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
centralize vscode.Uri usage #539
Conversation
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.
/describe
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.
/genai-describe
/genai-describe |
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.
/genai-review
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.
/genai-review
/genai-review |
The changes in the GIT_DIFF show that the developer is refactoring the code to use a new method However, there is a potential issue with the Here is a suggested fix: toUri(filenameOrUrl: string): vscode.Uri {
const folder = this.projectUri;
if (!filenameOrUrl) return folder;
if (/^[a-z][a-z0-9+\-.]*:\/\//.test(filenameOrUrl))
return vscode.Uri.parse(filenameOrUrl, true);
if (this.path.isAbsolute(filenameOrUrl))
return vscode.Uri.file(filenameOrUrl);
else return vscode.Uri.file(path.join(folder.fsPath, filenameOrUrl));
} This fix uses the Other than this issue, the changes look good. The developer has also removed some commented-out code, which is a good practice as it keeps the codebase clean. So, with the above fix, LGTM 🚀
|
vscode.Uri.parse
function now includes a second argument,true
, which allows parsing of URLs with strict mode enabled. This change affects multiple files includingbrowser.ts
,state.ts
, andvshost.ts
. 🌐applyEdits
function inedit.ts
now accepts an additional argument,state
, which is an instance ofExtensionState
. This change also affects the way URIs are created in the function. 📝activateFragmentCommands
function infragmentcommands.ts
and other similar functions now use thehost.toUri
method to create URIs instead ofvscode.Uri.file
. This change is also reflected in multiple other files. 🔄ExtensionState
class instate.ts
has been significantly refactored. A large block of error handling code has been removed, and thesaveScripts
andapplyEdits
methods now use thehost.toUri
method. 🧹activateStatusBar
function instatusbar.ts
now uses thehost
property ofstate
to create URIs. 📊activateTestController
function intestcontroller.ts
now uses thehost.toUri
method to create URIs. 🎮toUri
, has been added to theVSCodeHost
class invshost.ts
. This method creates avscode.Uri
from a filename or URL. 🆕In summary, these changes seem to centralize the creation of URIs in the
VSCodeHost
class, making the code more maintainable and consistent. 🎯