Skip to content

Commit 9b67efb

Browse files
authored
Add logging where we openTextDocument (#6133)
Part of #6109
1 parent 1e7cfe3 commit 9b67efb

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

src/github/prComment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import * as path from 'path';
77
import * as vscode from 'vscode';
88
import { IComment } from '../common/comment';
9+
import Logger from '../common/logger';
910
import { DataUri } from '../common/uri';
1011
import { ALLOWED_USERS, JSDOC_NON_USERS, PHPDOC_NON_USERS } from '../common/user';
1112
import { stringReplaceAsync } from '../common/utils';
@@ -197,6 +198,7 @@ const SUGGESTION_EXPRESSION = /```suggestion(\u0020*(\r\n|\n))((?<suggestion>[\s
197198
const IMG_EXPRESSION = /<img .*src=['"](?<src>.+?)['"].*?>/g;
198199

199200
export class GHPRComment extends CommentBase {
201+
private static ID = 'GHPRComment';
200202
public commentId: string;
201203
public timestamp: Date;
202204

@@ -379,6 +381,7 @@ ${lineContents}
379381
}
380382

381383
private async replaceBody(body: string | vscode.MarkdownString): Promise<string> {
384+
Logger.trace('Replace comment body', GHPRComment.ID);
382385
if (body instanceof vscode.MarkdownString) {
383386
const permalinkReplaced = await this.replacePermalink(body.value);
384387
return this.replaceImg(this.replaceSuggestion(permalinkReplaced));

src/issues/shareProviders.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as pathLib from 'path';
77
import * as vscode from 'vscode';
88
import { Commit, Remote, Repository } from '../api/api';
99
import { GitApiImpl } from '../api/api1';
10+
import Logger from '../common/logger';
1011
import { fromReviewUri, Schemes } from '../common/uri';
1112
import { FolderRepositoryManager } from '../github/folderRepositoryManager';
1213
import { RepositoriesManager } from '../github/repositoriesManager';
@@ -203,12 +204,14 @@ export class GitHubPermalinkShareProvider extends AbstractShareProvider implemen
203204
}
204205

205206
export class GitHubPermalinkAsMarkdownShareProvider extends GitHubPermalinkShareProvider {
207+
private static ID = 'GitHubPermalinkAsMarkdownShareProvider';
206208

207209
constructor(repositoryManager: RepositoriesManager, gitApi: GitApiImpl) {
208210
super(repositoryManager, gitApi, 'githubComPermalinkAsMarkdown', vscode.l10n.t('Copy GitHub Permalink as Markdown'), 12);
209211
}
210212

211213
async provideShare(item: vscode.ShareableItem): Promise<vscode.Uri | string | undefined> {
214+
Logger.trace('providing permalink markdown share', GitHubPermalinkAsMarkdownShareProvider.ID);
212215
const link = await super.provideShare(item);
213216

214217
const text = await this.getMarkdownLinkText(item);

src/issues/util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ async function findCodeLinksInIssue(body: string, repositoriesManager: Repositor
171171
return findAndModifyString(body, CODE_PERMALINK, async (match: RegExpMatchArray) => {
172172
const codeLink = await findCodeLinkLocally(match, repositoriesManager);
173173
if (codeLink) {
174+
Logger.trace('finding code links in issue', 'Issues');
174175
const textDocument = await vscode.workspace.openTextDocument(codeLink?.file);
175176
const endingTextDocumentLine = textDocument.lineAt(
176177
codeLink.end < textDocument.lineCount ? codeLink.end : textDocument.lineCount - 1,

src/view/pullRequestCommentController.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { v4 as uuid } from 'uuid';
88
import * as vscode from 'vscode';
99
import { CommentHandler, registerCommentHandler, unregisterCommentHandler } from '../commentHandlerResolver';
1010
import { DiffSide, IComment, SubjectType } from '../common/comment';
11+
import Logger from '../common/logger';
1112
import { ITelemetry } from '../common/telemetry';
1213
import { fromPRUri, Schemes } from '../common/uri';
1314
import { dispose, groupBy } from '../common/utils';
@@ -28,6 +29,7 @@ import {
2829
import { CommentControllerBase } from './commentControllBase';
2930

3031
export class PullRequestCommentController extends CommentControllerBase implements CommentHandler, CommentReactionHandler {
32+
private static ID = 'PullRequestCommentController';
3133
private _pendingCommentThreadAdds: GHPRCommentThread[] = [];
3234
private _commentHandlerId: string;
3335
private _commentThreadCache: { [key: string]: GHPRCommentThread[] } = {};
@@ -113,6 +115,7 @@ export class PullRequestCommentController extends CommentControllerBase implemen
113115
if (potentialEditor.editor) {
114116
return Promise.resolve(potentialEditor.editor.document);
115117
} else {
118+
Logger.trace(`Opening text document for PR editor ${potentialEditor.uri.toString()}`, PullRequestCommentController.ID);
116119
return vscode.workspace.openTextDocument(potentialEditor.uri);
117120
}
118121
}

src/view/reviewCommentController.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export class ReviewCommentController extends CommentControllerBase
229229
for (const [file, change] of (this._folderRepoManager.activePullRequest?.fileChanges.entries() ?? [])) {
230230
if (change.status !== GitChangeType.DELETE) {
231231
const uri = vscode.Uri.joinPath(this._folderRepoManager.repository.rootUri, file);
232+
Logger.trace(`Prefetching commenting ranges for ${uri.toString()}`, ReviewCommentController.ID);
232233
vscode.workspace.openTextDocument(uri);
233234
}
234235
}

0 commit comments

Comments
 (0)