Skip to content

Commit abf57b6

Browse files
committed
Updated jsDoc
1 parent 7d12320 commit abf57b6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

vscode/src/utils.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,24 +349,25 @@ export namespace FileUtils {
349349
/**
350350
* Converts a given file system path or URI-like string into a {@link vscode.Uri} instance.
351351
*
352-
* This utility attempts to correctly handle both raw file paths and strings that may
353-
* already represent a valid file URI.
352+
* This utility attempts to handle both raw file paths and strings that may already
353+
* represent a valid file URI.
354354
*
355355
* ### Behavior
356-
* - If `treatAsUriIfPossible` is **true** and the path starts with the file scheme
357-
* (`"file:"`), it assumes the input is already a valid URI and parses it
358-
* using `vscode.Uri.parse(path, true)`.
359-
* - Otherwise, it treats the input as a regular file system path and wraps it using
356+
* - If `treatAsUriIfPossible` is **true** and the input starts with the `"file:"` scheme,
357+
* it first attempts to parse the string using `vscode.Uri.parse(path, true)`.
358+
* - If parsing succeeds, the parsed URI is returned.
359+
* - If parsing fails, the error is logged (at debug level) and the method falls back
360+
* to treating the input as a regular file path.
361+
* - In all other cases or when fallback occurs, the input is wrapped using
360362
* `vscode.Uri.file(path)`.
361363
*
362-
* Any parsing errors are logged through the `LOGGER` and rethrown as a generic error.
364+
* Any unexpected errors during URI creation are logged and rethrown as a generic error.
363365
*
364366
* @param {string} path - The input file system path or URI-like string.
365367
* @param {boolean} [treatAsUriIfPossible=false] - If true, and the input starts with the
366-
* `file:` scheme, the path will be parsed directly as a URI instead of being wrapped
367-
* as a file URI.
368+
* `file:` scheme, the method attempts to parse it directly as a URI before falling back.
368369
* @returns {vscode.Uri} The resulting {@link vscode.Uri} object.
369-
* @throws {Error} When the input cannot be parsed into a valid URI.
370+
* @throws {Error} When both URI parsing and file wrapping fail.
370371
*/
371372
export const toUri = (path: string, treatAsUriIfPossible: boolean = false): vscode.Uri => {
372373
try {

0 commit comments

Comments
 (0)