Skip to content

Commit

Permalink
Handles all floating promises
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Aug 21, 2018
1 parent dd82de0 commit 3c05f84
Show file tree
Hide file tree
Showing 25 changed files with 76 additions and 72 deletions.
6 changes: 3 additions & 3 deletions src/annotations/annotationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export abstract class AnnotationProviderBase implements Disposable {

protected additionalDecorations: { decoration: TextEditorDecorationType; ranges: Range[] }[] | undefined;

async clear() {
clear() {
this.status = undefined;
if (this.editor === undefined) return;

Expand Down Expand Up @@ -110,10 +110,10 @@ export abstract class AnnotationProviderBase implements Disposable {
decoration: TextEditorDecorationType;
highlightDecoration: TextEditorDecorationType | undefined;
}
) => Promise<void>)
) => void)
| undefined;

async reset(changes?: {
reset(changes?: {
decoration: TextEditorDecorationType;
highlightDecoration: TextEditorDecorationType | undefined;
}) {
Expand Down
4 changes: 2 additions & 2 deletions src/annotations/blameAnnotationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
}
}

async clear() {
clear() {
this._hoverProviderDisposable && this._hoverProviderDisposable.dispose();
super.clear();
}
Expand All @@ -56,7 +56,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
: Container.git.getBlameForFile(this._uri);
}

super.onReset(changes);
return super.onReset(changes);
}

async selection(shaOrLine?: string | number, blame?: GitBlame) {
Expand Down
30 changes: 15 additions & 15 deletions src/annotations/fileAnnotationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class FileAnnotationController implements Disposable {
}

dispose() {
this.clearAll();
void this.clearAll();

Decorations.blameAnnotation && Decorations.blameAnnotation.dispose();
Decorations.blameHighlight && Decorations.blameHighlight.dispose();
Expand Down Expand Up @@ -155,21 +155,21 @@ export class FileAnnotationController implements Disposable {
if (initializing || configuration.changed(e, configuration.name('blame')('toggleMode').value)) {
this._toggleModes.set(FileAnnotationType.Blame, cfg.blame.toggleMode);
if (!initializing && cfg.blame.toggleMode === AnnotationsToggleMode.File) {
this.clearAll();
void this.clearAll();
}
}

if (initializing || configuration.changed(e, configuration.name('heatmap')('toggleMode').value)) {
this._toggleModes.set(FileAnnotationType.Heatmap, cfg.heatmap.toggleMode);
if (!initializing && cfg.heatmap.toggleMode === AnnotationsToggleMode.File) {
this.clearAll();
void this.clearAll();
}
}

if (initializing || configuration.changed(e, configuration.name('recentChanges')('toggleMode').value)) {
this._toggleModes.set(FileAnnotationType.RecentChanges, cfg.recentChanges.toggleMode);
if (!initializing && cfg.recentChanges.toggleMode === AnnotationsToggleMode.File) {
this.clearAll();
void this.clearAll();
}
}

Expand Down Expand Up @@ -198,7 +198,7 @@ export class FileAnnotationController implements Disposable {
});
}
else {
this.show(provider.editor, FileAnnotationType.Heatmap);
void this.show(provider.editor, FileAnnotationType.Heatmap);
}
}
}
Expand All @@ -219,11 +219,11 @@ export class FileAnnotationController implements Disposable {
const provider = this.getProvider(editor);
if (provider === undefined) {
setCommandContext(CommandContext.AnnotationStatus, undefined);
this.detachKeyboardHook();
void this.detachKeyboardHook();
}
else {
setCommandContext(CommandContext.AnnotationStatus, provider.status);
this.attachKeyboardHook();
void this.attachKeyboardHook();
}
}

Expand All @@ -234,14 +234,14 @@ export class FileAnnotationController implements Disposable {
const editor = window.activeTextEditor;
if (editor === undefined) return;

this.clear(editor, AnnotationClearReason.BlameabilityChanged);
void this.clear(editor, AnnotationClearReason.BlameabilityChanged);
}

private onDirtyStateChanged(e: DocumentDirtyStateChangeEvent<GitDocumentState>) {
for (const [key, p] of this._annotationProviders) {
if (!e.document.is(p.document)) continue;

this.clearCore(key, AnnotationClearReason.DocumentChanged);
void this.clearCore(key, AnnotationClearReason.DocumentChanged);
}
}

Expand All @@ -251,7 +251,7 @@ export class FileAnnotationController implements Disposable {
for (const [key, p] of this._annotationProviders) {
if (p.document !== document) continue;

this.clearCore(key, AnnotationClearReason.DocumentClosed);
void this.clearCore(key, AnnotationClearReason.DocumentClosed);
}
}

Expand All @@ -266,12 +266,12 @@ export class FileAnnotationController implements Disposable {
);
if (fuzzyProvider == null) return;

this.clearCore(fuzzyProvider.correlationKey, AnnotationClearReason.ColumnChanged);
void this.clearCore(fuzzyProvider.correlationKey, AnnotationClearReason.ColumnChanged);

return;
}

provider.restore(e.textEditor);
void provider.restore(e.textEditor);
}

private onVisibleTextEditorsChanged(editors: TextEditor[]) {
Expand All @@ -280,7 +280,7 @@ export class FileAnnotationController implements Disposable {
provider = this.getProvider(e);
if (provider === undefined) continue;

provider.restore(e);
void provider.restore(e);
}
}

Expand Down Expand Up @@ -344,7 +344,7 @@ export class FileAnnotationController implements Disposable {
for (const e of window.visibleTextEditors) {
if (e === editor) continue;

this.show(e, type);
void this.show(e, type);
}
}
}
Expand Down Expand Up @@ -495,7 +495,7 @@ export class FileAnnotationController implements Disposable {
}

// Allows pressing escape to exit the annotations
this.attachKeyboardHook();
await this.attachKeyboardHook();

const trackedDocument = await Container.tracker.getOrAdd(editor.document);

Expand Down
2 changes: 1 addition & 1 deletion src/annotations/gutterBlameAnnotationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
Logger.log(`${duration[0] * 1000 + Math.floor(duration[1] / 1000000)} ms to compute gutter blame annotations`);

this.registerHoverProviders(Container.config.hovers.annotations);
this.selection(shaOrLine, blame);
void this.selection(shaOrLine, blame);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/annotations/heatmapBlameAnnotationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class HeatmapBlameAnnotationProvider extends BlameAnnotationProviderBase
Logger.log(`${duration[0] * 1000 + Math.floor(duration[1] / 1000000)} ms to compute heatmap annotations`);

this.registerHoverProviders(Container.config.hovers.annotations);
this.selection(shaOrLine, blame);
void this.selection(shaOrLine, blame);
return true;
}
}
12 changes: 6 additions & 6 deletions src/annotations/lineAnnotationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class LineAnnotationController implements Disposable {
}
}

this.refresh(window.activeTextEditor);
void this.refresh(window.activeTextEditor);
}

private _suspended?: 'debugging' | 'user';
Expand Down Expand Up @@ -107,7 +107,7 @@ export class LineAnnotationController implements Disposable {

private onActiveLinesChanged(e: LinesChangeEvent) {
if (!e.pending && e.lines !== undefined) {
this.refresh(e.editor);
void this.refresh(e.editor);

return;
}
Expand All @@ -121,7 +121,7 @@ export class LineAnnotationController implements Disposable {
}

if (this.suspend('debugging')) {
this.refresh(window.activeTextEditor);
void this.refresh(window.activeTextEditor);
}
}

Expand All @@ -132,15 +132,15 @@ export class LineAnnotationController implements Disposable {
}

if (this.resume('debugging')) {
this.refresh(window.activeTextEditor);
void this.refresh(window.activeTextEditor);
}
}

private onFileAnnotationsToggled() {
this.refresh(window.activeTextEditor);
void this.refresh(window.activeTextEditor);
}

async clear(editor: TextEditor | undefined) {
clear(editor: TextEditor | undefined) {
if (this._editor !== editor && this._editor !== undefined) {
this.clearAnnotations(this._editor);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/diffDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
if (args.ref1 === undefined) return undefined;
}

Container.git.openDirectoryDiff(repoPath, args.ref1, args.ref2);
await Container.git.openDirectoryDiff(repoPath, args.ref1, args.ref2);
return undefined;
}
catch (ex) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/externalDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class ExternalDiffCommand extends Command {
}

for (const file of args.files) {
Container.git.openDiffTool(repoPath, file.uri, file.staged, tool);
void Container.git.openDiffTool(repoPath, file.uri, file.staged, tool);
}

return undefined;
Expand Down
8 changes: 4 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function activate(context: ExtensionContext) {
Logger.log(`GitLens(v${gitlensVersion}) was NOT activated -- "git.enabled": false`);
setCommandContext(CommandContext.Enabled, enabled);

Messages.showGitDisabledErrorMessage();
void Messages.showGitDisabledErrorMessage();

return;
}
Expand Down Expand Up @@ -92,8 +92,8 @@ export async function activate(context: ExtensionContext) {
// Telemetry.setContext(telemetryContext);

notifyOnUnsupportedGitVersion(gitVersion);
showWelcomePage(gitlensVersion, previousVersion);
Messages.showKeyBindingsInfoMessage();
void showWelcomePage(gitlensVersion, previousVersion);
void Messages.showKeyBindingsInfoMessage();

context.globalState.update(GlobalState.GitLensVersion, gitlensVersion);

Expand Down Expand Up @@ -502,7 +502,7 @@ function notifyOnUnsupportedGitVersion(version: string) {
if (GitService.compareGitVersion('2.2.0') !== -1) return;

// If git is less than v2.2.0
Messages.showGitVersionUnsupportedErrorMessage(version);
void Messages.showGitVersionUnsupportedErrorMessage(version);
}

async function showWelcomePage(version: string, previousVersion: string | undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/commitFileQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class CommitFileQuickPick {
} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.getShortMessage()}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {
scope.setKeyCommand('right', item as KeyCommand);
void scope.setKeyCommand('right', item as KeyCommand);
}
} as QuickPickOptions);

Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/commitQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export class CommitQuickPick {
}${commit.formattedDate} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.getShortMessage()}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {
scope.setKeyCommand('right', item);
void scope.setKeyCommand('right', item);
if (typeof item.onDidSelect === 'function') {
item.onDidSelect();
}
Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/commonQuickPicks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getQuickPickIgnoreFocusOut() {

export function showQuickPickProgress(message: string, mapping?: KeyMapping): CancellationTokenSource {
const cancellation = new CancellationTokenSource();
_showQuickPickProgress(message, cancellation, mapping);
void _showQuickPickProgress(message, cancellation, mapping);
return cancellation;
}

Expand Down
2 changes: 1 addition & 1 deletion src/quickpicks/repoStatusQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export class RepoStatusQuickPick {
}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {
scope.setKeyCommand('right', item);
void scope.setKeyCommand('right', item);
}
} as QuickPickOptions);

Expand Down
2 changes: 1 addition & 1 deletion src/statusbar/statusBarController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class StatusBarController implements Disposable {
}
}

async clearBlame() {
clearBlame() {
if (this._blameStatusBarItem !== undefined) {
this._blameStatusBarItem.hide();
}
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/activeEditorTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export class ActiveEditorTracker implements Disposable {
}

async awaitClose(timeout: number = 500): Promise<TextEditor | undefined> {
this.close();
void this.close();
return this.wait(timeout);
}

async awaitNext(timeout: number = 500): Promise<TextEditor | undefined> {
this.next();
void this.next();
return this.wait(timeout);
}

Expand Down
2 changes: 1 addition & 1 deletion src/trackers/documentTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class DocumentTracker<T> implements Disposable {
private onTextDocumentSaved(document: TextDocument) {
let doc = this._documentMap.get(document);
if (doc !== undefined) {
doc.update({ forceBlameChange: true });
void doc.update({ forceBlameChange: true });

return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/trackers/gitLineTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class GitLineTracker extends LineTracker<GitLineState> {
updated = await this.updateState(e.lines, e.editor);
}

super.fireLinesChanged(updated ? e : { ...e, lines: undefined });
return super.fireLinesChanged(updated ? e : { ...e, lines: undefined });
}

private onBlameStateChanged(e: DocumentBlameStateChangeEvent<GitDocumentState>) {
Expand All @@ -56,14 +56,14 @@ export class GitLineTracker extends LineTracker<GitLineState> {

private _suspended = false;

private async resume(options: { force?: boolean } = {}) {
private resume(options: { force?: boolean } = {}) {
if (!options.force && !this._suspended) return;

this._suspended = false;
this.trigger('editor');
}

private async suspend(options: { force?: boolean } = {}) {
private suspend(options: { force?: boolean } = {}) {
if (!options.force && this._suspended) return;

this._suspended = true;
Expand Down
6 changes: 3 additions & 3 deletions src/trackers/lineTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class LineTracker<T> implements Disposable {
this._linesChangedDebounced.cancel();
}

this.fireLinesChanged(e);
void this.fireLinesChanged(e);
});

return;
Expand All @@ -137,7 +137,7 @@ export class LineTracker<T> implements Disposable {
return;
}

this.fireLinesChanged(e);
void this.fireLinesChanged(e);
},
250,
{ track: true }
Expand All @@ -146,7 +146,7 @@ export class LineTracker<T> implements Disposable {

// If we have no pending moves, then fire an immediate pending event, and defer the real event
if (!this._linesChangedDebounced.pending!()) {
this.fireLinesChanged({ ...e, pending: true });
void this.fireLinesChanged({ ...e, pending: true });
}

this._linesChangedDebounced(e);
Expand Down

0 comments on commit 3c05f84

Please sign in to comment.