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

Deal with less common file hyperlinks on Windows #2416

Merged
merged 2 commits into from
Mar 12, 2024
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 @@ -4,6 +4,7 @@

import 'vs/css!./outputRun';
import * as React from 'react';
import * as platform from 'vs/base/common/platform';
import { CSSProperties, MouseEvent } from 'react'; // eslint-disable-line no-duplicate-imports
import { localize } from 'vs/nls';
import { ANSIColor, ANSIOutputRun, ANSIStyle } from 'vs/base/common/ansiOutput';
Expand All @@ -14,6 +15,7 @@ import { Schemas } from 'vs/base/common/network';
* Constants.
*/
const numberRegex = /^\d+$/;
const fileURLThatNeedsASlash = /^(file:\/\/)([a-zA-Z]:)/;
const fileURLWithLine = /^(file:\/\/\/.+):(\d+)$/;
const fileURLWithLineAndColumn = /^(file:\/\/\/.+):(\d+):(\d+)$/;

Expand Down Expand Up @@ -56,6 +58,17 @@ export const OutputRun = (props: OutputRunProps) => {
return url;
}

// anticipate file URLs produced by, e.g., some versions of the cli R package
// BEFORE example:
// file://D:\\Users\\jenny\\source\\repos\\glue\\tests\\testthat\\test-glue.R
// AFTER example:
// file:///D:/Users/jenny/source/repos/glue/tests/testthat/test-glue.R
if (platform.isWindows) {
url = url
.replace(/\\/g, '/')
.replace(fileURLThatNeedsASlash, '$1/$2');
}

// Get the line parameter. If it's not present, return the URL.
const line = props.outputRun.hyperlink.params?.get('line') || undefined;
if (!line) {
Expand Down
Loading