Skip to content

Commit 106587b

Browse files
committed
Add https handler
1 parent dfb7860 commit 106587b

File tree

1 file changed

+38
-19
lines changed

1 file changed

+38
-19
lines changed

VSDebugEditorExtension.cs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -409,29 +409,48 @@ private void UpdateWordAdornments(object threadContext)
409409
var lineStartPos = SourceBuffer.CurrentSnapshot.GetLineFromPosition(RequestedPoint).Start.Position;
410410
var lineCaretPos = RequestedPoint.Position - lineStartPos;
411411

412-
var fileStartPos = -1;
413-
var fileEndPos = -1;
412+
var token = clickLineSelection.IndexOf("file://", StringComparison.Ordinal) > 0 ?
413+
"file://" :
414+
clickLineSelection.IndexOf("https://", StringComparison.Ordinal) > 0 ?
415+
"https://" :
416+
null;
417+
418+
var tokenStartPos = -1;
419+
var tokenEndPos = -1;
414420
var foundWord = false;
415421

416-
if ((fileStartPos = clickLineSelection.IndexOf("file://", StringComparison.Ordinal)) > 0 &&
417-
(fileEndPos = clickLineSelection.IndexOf(">", StringComparison.Ordinal)) > 0 &&
418-
fileEndPos > fileStartPos && lineCaretPos > fileStartPos && lineCaretPos < fileEndPos &&
419-
fileStartPos >= 0 && fileEndPos >= 0)
422+
if ((token != null) &&
423+
(tokenStartPos = clickLineSelection.IndexOf(token, StringComparison.Ordinal)) > 0 &&
424+
(tokenEndPos = clickLineSelection.IndexOf(">", StringComparison.Ordinal)) > 0 &&
425+
tokenEndPos > tokenStartPos && lineCaretPos > tokenStartPos && lineCaretPos < tokenEndPos &&
426+
tokenStartPos >= 0 && tokenEndPos >= 0)
420427
{
421-
fileStartPos += "file://".Length;
428+
foundWord = true;
422429

423-
var strFilePath = clickLineSelection.Substring(fileStartPos, fileEndPos - fileStartPos);
424-
425-
if (File.Exists(strFilePath))
430+
switch (token)
426431
{
427-
var strExt = Path.GetExtension(strFilePath);
428-
429-
foundWord = true;
430-
431-
var editorTool = VSDebugProPackage.Context.Settings.GetAssignedTool(strExt);
432-
433-
if (editorTool != string.Empty) Process.Start(editorTool, strFilePath);
432+
case "file://":
433+
{
434+
tokenStartPos += token.Length;
435+
var strFilePath = clickLineSelection.Substring(tokenStartPos, tokenEndPos - tokenStartPos);
436+
if (File.Exists(strFilePath))
437+
{
438+
var strExt = Path.GetExtension(strFilePath);
439+
440+
var editorTool = VSDebugProPackage.Context.Settings.GetAssignedTool(strExt);
441+
442+
if (editorTool != string.Empty) Process.Start(editorTool, strFilePath);
443+
}
444+
}
445+
break;
446+
case "https://":
447+
{
448+
var strUrl = clickLineSelection.Substring(tokenStartPos, tokenEndPos - tokenStartPos);
449+
Process.Start(strUrl);
450+
}
451+
break;
434452
}
453+
435454
}
436455

437456
if (!foundWord)
@@ -442,8 +461,8 @@ private void UpdateWordAdornments(object threadContext)
442461
}
443462

444463
var currentWord = new SnapshotSpan(
445-
new SnapshotPoint(SourceBuffer.CurrentSnapshot, lineStartPos + fileStartPos),
446-
new SnapshotPoint(SourceBuffer.CurrentSnapshot, lineStartPos + fileEndPos));
464+
new SnapshotPoint(SourceBuffer.CurrentSnapshot, lineStartPos + tokenStartPos),
465+
new SnapshotPoint(SourceBuffer.CurrentSnapshot, lineStartPos + tokenEndPos));
447466

448467
// If this is the same word we currently have, we're done (e.g. caret moved within a word).
449468
if (CurrentWord.HasValue && currentWord == CurrentWord)

0 commit comments

Comments
 (0)