Browse Source

Closes #321 - re-adds support for single files

main
Eric Amodio 6 years ago
parent
commit
cbd5612740
3 changed files with 27 additions and 14 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +9
    -3
      src/git/models/repository.ts
  3. +14
    -11
      src/gitService.ts

+ 4
- 0
CHANGELOG.md View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Added
- Adds (re-adds) support for handling single files — closes [#321](https://github.com/eamodio/vscode-gitlens/issues/321)
## [8.3.2] - 2018-05-21 ## [8.3.2] - 2018-05-21
### Fixed ### Fixed
- Fixes [#366](https://github.com/eamodio/vscode-gitlens/issues/366) - Running a GitLens command from a keybinding fails (more cases) - Fixes [#366](https://github.com/eamodio/vscode-gitlens/issues/366) - Running a GitLens command from a keybinding fails (more cases)

+ 9
- 3
src/git/models/repository.ts View File

@ -88,9 +88,15 @@ export class Repository extends Disposable {
) { ) {
super(() => this.dispose()); super(() => this.dispose());
this.formattedName = root
? folder.name
: `${folder.name} (${_path.relative(folder.uri.fsPath, path)})`;
if (root) {
this.formattedName = folder.name;
}
else {
const relativePath = _path.relative(folder.uri.fsPath, path);
this.formattedName = relativePath
? `${folder.name} (${relativePath})`
: folder.name;
}
this.index = folder.index; this.index = folder.index;
this.name = folder.name; this.name = folder.name;

+ 14
- 11
src/gitService.ts View File

@ -1193,7 +1193,7 @@ export class GitService extends Disposable {
if (filePathOrUri instanceof GitUri) return filePathOrUri.repoPath; if (filePathOrUri instanceof GitUri) return filePathOrUri.repoPath;
// Don't save the tracking info to the cache, because we could be looking in the wrong place (e.g. looking in the root when the file is in a submodule) // Don't save the tracking info to the cache, because we could be looking in the wrong place (e.g. looking in the root when the file is in a submodule)
const repo = await this.getRepository(filePathOrUri, { ...options, skipCacheUpdate: true });
let repo = await this.getRepository(filePathOrUri, { ...options, skipCacheUpdate: true });
if (repo !== undefined) return repo.path; if (repo !== undefined) return repo.path;
if (typeof filePathOrUri !== 'string') { if (typeof filePathOrUri !== 'string') {
@ -1209,21 +1209,24 @@ export class GitService extends Disposable {
// If this new repo is inside one of our known roots and we we don't already know about, add it // If this new repo is inside one of our known roots and we we don't already know about, add it
const root = this._repositoryTree.findSubstr(rp); const root = this._repositoryTree.findSubstr(rp);
const folder = root === undefined
let folder = root === undefined
? workspace.getWorkspaceFolder(Uri.file(rp)) ? workspace.getWorkspaceFolder(Uri.file(rp))
: root.folder; : root.folder;
if (folder !== undefined) {
const repo = new Repository(folder, rp, false, this.onAnyRepositoryChanged.bind(this), this._suspended);
this._repositoryTree.set(rp, repo);
if (folder === undefined) {
const parts = rp.split('/');
folder = { uri: Uri.file(rp), name: parts[parts.length - 1], index: this._repositoryTree.count() };
}
// Send a notification that the repositories changed
setImmediate(async () => {
await this.updateContext(this._repositoryTree);
repo = new Repository(folder, rp, false, this.onAnyRepositoryChanged.bind(this), this._suspended);
this._repositoryTree.set(rp, repo);
this.fireRepositoriesChanged();
});
}
// Send a notification that the repositories changed
setImmediate(async () => {
await this.updateContext(this._repositoryTree);
this.fireRepositoriesChanged();
});
return rp; return rp;
} }

Loading…
Cancel
Save