소스 검색

Avoids casts

main
Eric Amodio 4 년 전
부모
커밋
497c4ac2f0
5개의 변경된 파일7개의 추가작업 그리고 17개의 파일을 삭제
  1. +2
    -12
      src/annotations/blameAnnotationProvider.ts
  2. +1
    -1
      src/annotations/gutterChangesAnnotationProvider.ts
  3. +1
    -1
      src/commands/gitCommands.actions.ts
  4. +2
    -2
      src/git/gitService.ts
  5. +1
    -1
      src/git/parsers/statusParser.ts

+ 2
- 12
src/annotations/blameAnnotationProvider.ts 파일 보기

@ -1,15 +1,5 @@
'use strict';
import {
CancellationToken,
Disposable,
Hover,
languages,
MarkdownString,
Position,
Range,
TextDocument,
TextEditor,
} from 'vscode';
import { CancellationToken, Disposable, Hover, languages, Position, Range, TextDocument, TextEditor } from 'vscode';
import { AnnotationProviderBase } from './annotationProvider';
import { ComputedHeatmap, getHeatmapColors } from './annotations';
import { Container } from '../container';
@ -165,7 +155,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
? Hovers.changesMessage(commit, await GitUri.fromUri(document.uri), position.line)
: undefined,
])
).filter(Boolean) as MarkdownString[];
).filter(<T>(m?: T): m is T => Boolean(m));
return new Hover(
messages,

+ 1
- 1
src/annotations/gutterChangesAnnotationProvider.ts 파일 보기

@ -138,7 +138,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase {
]
: [Container.git.getDiffForFile(this.trackedDocument.uri, ref1, ref2)],
)
).filter(Boolean) as GitDiff[];
).filter(<T>(d?: T): d is T => Boolean(d));
if (!diffs?.length) return false;
let start = process.hrtime();

+ 1
- 1
src/commands/gitCommands.actions.ts 파일 보기

@ -595,7 +595,7 @@ export namespace GitActions {
await Promise.all(
files.map(file => Container.git.getWorkingUri(repoPath!, GitUri.fromFile(file, repoPath!, ref))),
)
).filter(Boolean) as Uri[];
).filter(<T>(u?: T): u is T => Boolean(u));
findOrOpenEditors(uris);
}

+ 2
- 2
src/git/gitService.ts 파일 보기

@ -542,7 +542,7 @@ export class GitService implements Disposable {
const data = await Git.check_ignore(repoPath, ...paths.keys());
if (data == null) return uris;
const ignored = data.split('\0').filter(Boolean);
const ignored = data.split('\0').filter(<T>(i?: T): i is T => Boolean(i));
if (ignored.length === 0) return uris;
for (const file of ignored) {
@ -1174,7 +1174,7 @@ export class GitService implements Disposable {
return data
.split('\n')
.map(b => b.substr(2).trim())
.filter(Boolean);
.filter(<T>(i?: T): i is T => Boolean(i));
}
@log()

+ 1
- 1
src/git/parsers/statusParser.ts 파일 보기

@ -12,7 +12,7 @@ export class GitStatusParser {
static parse(data: string, repoPath: string, porcelainVersion: number): GitStatus | undefined {
if (!data) return undefined;
const lines = data.split('\n').filter(Boolean);
const lines = data.split('\n').filter(<T>(i?: T): i is T => Boolean(i));
if (lines.length === 0) return undefined;
if (porcelainVersion < 2) return this.parseV1(lines, repoPath);

불러오는 중...
취소
저장