Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected openFile(change: GitFileChange, commitSha: string): void {
const uri: URI = new URI(change.uri);
let fromURI = change.oldUri ? new URI(change.oldUri) : uri; // set oldUri on renamed and copied
fromURI = fromURI.withScheme(GIT_RESOURCE_SCHEME).withQuery(commitSha + '~1');
const toURI = uri.withScheme(GIT_RESOURCE_SCHEME).withQuery(commitSha);
let uriToOpen = uri;
if (change.status === GitFileStatus.Deleted) {
uriToOpen = fromURI;
} else if (change.status === GitFileStatus.New) {
uriToOpen = toURI;
} else {
uriToOpen = DiffUris.encode(fromURI, toURI);
}
open(this.openerService, uriToOpen, { mode: 'reveal' });
}
}
enableAllBreakpoints(enabled: boolean): void {
for (const uriString of this.getUris()) {
let didChange = false;
const uri = new URI(uriString);
const markers = this.findMarkers({ uri });
for (const marker of markers) {
if (marker.data.enabled !== enabled) {
marker.data.enabled = enabled;
didChange = true;
}
}
if (didChange) {
this.fireOnDidChangeMarkers(uri);
}
}
}
protected updateStatusBar(): void {
this.statusBarDisposable.dispose();
const repository = this.scmService.selectedRepository;
if (!repository) {
return;
}
const name = this.labelProvider.getName(new URI(repository.provider.rootUri));
if (this.scmService.repositories.length > 1) {
this.setStatusBarEntry(SCM_COMMANDS.CHANGE_REPOSITORY.id, {
text: `$(database) ${name}`,
tooltip: name.toString(),
command: SCM_COMMANDS.CHANGE_REPOSITORY.id,
alignment: StatusBarAlignment.LEFT,
priority: 100
});
}
const label = repository.provider.rootUri ? `${name} (${repository.provider.label})` : repository.provider.label;
this.scmService.statusBarCommands.forEach((value, index) => this.setStatusBarEntry(`scm.status.${index}`, {
text: value.title,
tooltip: label + (value.tooltip ? ` - ${value.tooltip}` : ''),
command: value.command,
arguments: value.arguments,
alignment: StatusBarAlignment.LEFT,
provideDocumentSymbols(model: monaco.editor.ITextModel): monaco.languages.DocumentSymbol[] {
if (new URI(model.uri.toString()).path.base !== 'launch.json') {
return [];
}
const children: monaco.languages.DocumentSymbol[] = [];
const result: monaco.languages.DocumentSymbol = {
name: 'Launch Configurations',
detail: '',
kind: monaco.languages.SymbolKind.Object,
range: new monaco.Range(0, 0, 0, 0),
selectionRange: new monaco.Range(0, 0, 0, 0),
children
};
let name: string = '';
let lastProperty = '';
let startOffset = 0;
let depthInObjects = 0;
return;
}
this.styleSheetContent = '';
this.toUnload.push(Disposable.create(() => {
this.styleSheetContent = undefined;
this.hasFileIcons = undefined;
this.hasFolderIcons = undefined;
this.hidesExplorerArrows = undefined;
this.icons.clear();
}));
const { content } = await this.fileSystem.resolveContent(this.uri);
const json: RecursivePartial = jsoncparser.parse(content, undefined, { disallowComments: false });
this.hidesExplorerArrows = !!json.hidesExplorerArrows;
const uri = new URI(this.uri);
const toUnwatch = await this.fsWatcher.watchFileChanges(uri);
if (this.toUnload.disposed) {
toUnwatch.dispose();
} else {
this.toUnload.push(toUnwatch);
this.toUnload.push(this.fsWatcher.onFilesChanged(e => {
if (FileChangeEvent.isChanged(e, uri)) {
this.reload();
}
}));
}
const iconDefinitions = json.iconDefinitions;
if (!iconDefinitions) {
return;
}
isBlameable(uri: string): boolean {
return !!this.repositoryTracker.getPath(new URI(uri));
}
protected async updateView(status: WorkingDirectoryStatus | undefined) {
const stagedChanges = [];
const unstagedChanges = [];
const mergeChanges = [];
if (status) {
for (const change of status.changes) {
const uri = new URI(change.uri);
const repository = this.repositoryProvider.selectedRepository;
const [icon, label, description] = await Promise.all([
this.labelProvider.getIcon(uri),
this.labelProvider.getName(uri),
repository ? Repository.relativePath(repository, uri.parent).toString() : this.labelProvider.getLongName(uri.parent)
]);
if (GitFileStatus[GitFileStatus.Conflicted.valueOf()] !== GitFileStatus[change.status]) {
if (change.staged) {
stagedChanges.push({
icon, label, description,
...change
});
} else {
unstagedChanges.push({
icon, label, description,
...change
workspaceService.root.then(root => {
if (root) {
this.rootUri = new URI(root.uri);
}
});
}
protected renderPath(): React.ReactNode {
if (this.options.uri) {
const path = this.gitLabelProvider.relativePath(this.options.uri);
if (path.length > 0) {
return '/' + path;
} else {
return this.labelProvider.getLongName(new URI(this.options.uri));
}
}
return null;
}
const children = !parent.children ? [] : parent.children!.map(child => new URI(child.uri));