Skip to content

Commit

Permalink
Better filtering of .hg events vs. workspace events. Fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Crowl committed Jun 17, 2017
1 parent 5522e4b commit 48aef4e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,22 @@ export class Model implements Disposable {
disposables.push(watcher);

const onHgChange = mapEvent(onRawHgChange, ({ filename }) => Uri.file(path.join(dotHgPath, filename)));
const onRelevantHgChange = filterEvent(onHgChange, uri => !/\/\.hg\/index\.lock$/.test(uri.fsPath));
const onHgrcChange = filterEvent(onHgChange, uri => /\/\.hg\/hgrc$/.test(uri.path));
const onRelevantHgChange = filterEvent(onHgChange, uri => {
const isRelevant = !/[\\\/]\.hg[\\\/](\w?lock.*|.*\.log)$/.test(uri.fsPath);
return isRelevant;
});
const onHgrcChange = filterEvent(onHgChange, uri => {
const isHgrc = /[\\\/]\.hg[\\\/]hgrc$/.test(uri.fsPath);
return isHgrc;
});
onRelevantHgChange(this.onFSChange, this, disposables);
onRelevantHgChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, disposables);
onHgrcChange(this.onHgrcChange, this, disposables);

const onNonHgChange = filterEvent(this.onWorkspaceChange, uri => !/\/\.hg\//.test(uri.fsPath));
const onNonHgChange = filterEvent(this.onWorkspaceChange, uri => {
const isNonHgChange = !/[\\\/]\.hg[\\\/]?/.test(uri.fsPath);
return isNonHgChange
});
onNonHgChange(this.onFSChange, this, disposables);

this.repositoryDisposable = combinedDisposable(disposables);
Expand Down

1 comment on commit 48aef4e

@ajansveld
Copy link

@ajansveld ajansveld commented on 48aef4e Jun 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to completely fix the behavior reported in #14. If the blackbox extension is enabled, vscode keeps running hg cat against the active file (if it is in the current repository).

Tested with Mercurial 4.2.1, latest vscode and extension 1.1.4.

Please sign in to comment.