Skip to content

Commit

Permalink
watcher - enable nsfw by default on macOS and Windows and add a set…
Browse files Browse the repository at this point in the history
…ting to disable that (#132483)
  • Loading branch information
bpasero committed Sep 21, 2021
1 parent 4f8e969 commit 4211a1a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/vs/platform/files/node/diskFileSystemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface IWatcherOptions {
export interface IDiskFileSystemProviderOptions {
bufferSize?: number;
watcher?: IWatcherOptions;
enableLegacyRecursiveWatcher?: boolean;
}

export class DiskFileSystemProvider extends Disposable implements
Expand Down Expand Up @@ -609,8 +610,18 @@ export class DiskFileSystemProvider extends Disposable implements

else {

// Conditionally fallback to our legacy file watcher:
// - If provided as option from the outside (i.e. via settings)
// - Linux: until we support ignore patterns (unless insiders)
let enableLegacyWatcher: boolean;
if (this.options?.enableLegacyRecursiveWatcher) {
enableLegacyWatcher = true;
} else {
enableLegacyWatcher = product.quality === 'stable' && isLinux;
}

// Single Folder Watcher (stable only)
if (product.quality === 'stable' && this.recursiveFoldersToWatch.length === 1) {
if (enableLegacyWatcher && this.recursiveFoldersToWatch.length === 1) {
if (isWindows) {
watcherImpl = WindowsWatcherService;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class NsfwWatcherService extends Disposable implements IWatcherService {
// - the path uses wrong casing
// - the path is a symbolic link
// We have to detect this case and massage the events to correct this.
// Note: Other platforms do not seem to have these path issues.
let realBasePathDiffers = false;
let realBasePathLength = request.path.length;
if (isMacintosh) {
Expand Down
2 changes: 2 additions & 0 deletions src/vs/platform/windows/common/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ export interface INativeWindowConfiguration extends IWindowConfiguration, Native
maximized?: boolean;
accessibilitySupport?: boolean;

enableLegacyRecursiveWatcher?: boolean; // TODO@bpasero remove me once watcher is settled

perfMarks: PerformanceMark[];

filesToWait?: IPathsToWaitFor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
os: { release: release(), hostname: hostname() },
zoomLevel: typeof windowConfig?.zoomLevel === 'number' ? windowConfig.zoomLevel : undefined,

enableLegacyRecursiveWatcher: this.configurationService.getValue('files.legacyWatcher'),
autoDetectHighContrast: windowConfig?.autoDetectHighContrast ?? true,
accessibilitySupport: app.accessibilitySupportEnabled,
colorScheme: {
Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/contrib/files/browser/files.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/file
import { BinaryFileEditor } from 'vs/workbench/contrib/files/browser/editors/binaryFileEditor';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { isNative, isWeb, isWindows } from 'vs/base/common/platform';
import { isLinux, isNative, isWeb, isWindows } from 'vs/base/common/platform';
import { ExplorerViewletViewsContribution } from 'vs/workbench/contrib/files/browser/explorerViewlet';
import { IEditorPaneRegistry, EditorPaneDescriptor } from 'vs/workbench/browser/editor';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
Expand All @@ -34,6 +34,7 @@ import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { IExplorerService } from 'vs/workbench/contrib/files/browser/files';
import { FileEditorInputSerializer, FileEditorWorkingCopyEditorHandler } from 'vs/workbench/contrib/files/browser/editors/fileEditorHandler';
import { ModesRegistry } from 'vs/editor/common/modes/modesRegistry';
import product from 'vs/platform/product/common/product';

class FileUriLabelContribution implements IWorkbenchContribution {

Expand Down Expand Up @@ -247,6 +248,11 @@ configurationRegistry.registerConfiguration({
'markdownDescription': nls.localize('watcherExclude', "Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths, i.e. prefix with `**/` or the full path to match properly and suffix with `/**` to match files within a path (for example `**/build/output/**` or `/Users/name/workspaces/project/build/output/**`). Changing this setting requires a restart. When you experience Code consuming lots of CPU time on startup, you can exclude large folders to reduce the initial load."),
'scope': ConfigurationScope.RESOURCE
},
'files.legacyWatcher': {
'type': 'boolean',
'default': product.quality === 'stable' && isLinux,
'description': nls.localize('legacyWatcher', "Controls the mechanism used for file watching. Only change this when you see issues related to file watching."),
},
'files.hotExit': hotExitConfiguration,
'files.defaultLanguage': {
'type': 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ interface IConfiguration extends IWindowsConfiguration {
update: { mode: string; };
debug: { console: { wordWrap: boolean } };
editor: { accessibilitySupport: 'on' | 'off' | 'auto' };
security: { workspace: { trust: { enabled: boolean } } }
security: { workspace: { trust: { enabled: boolean } } };
files: { legacyWatcher: boolean };
}

export class SettingsChangeRelauncher extends Disposable implements IWorkbenchContribution {
Expand All @@ -37,6 +38,7 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
private updateMode: string | undefined;
private accessibilitySupport: 'on' | 'off' | 'auto' | undefined;
private workspaceTrustEnabled: boolean | undefined;
private legacyFileWatcher: boolean | undefined = undefined;

constructor(
@IHostService private readonly hostService: IHostService,
Expand Down Expand Up @@ -98,6 +100,12 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
this.workspaceTrustEnabled = config.security.workspace.trust.enabled;
changed = true;
}

// Legacy File Watcher
if (typeof config.files?.legacyWatcher === 'boolean' && config.files.legacyWatcher !== this.legacyFileWatcher) {
this.legacyFileWatcher = config.files.legacyWatcher;
changed = true;
}
}

// Notify only when changed and we are the focused window (avoids notification spam across windows)
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-browser/desktop.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DesktopMain extends SharedDesktopMain {
protected registerFileSystemProviders(environmentService: INativeWorkbenchEnvironmentService, fileService: IFileService, logService: ILogService, nativeHostService: INativeHostService): void {

// Local Files
const diskFileSystemProvider = this._register(new DiskFileSystemProvider(logService, nativeHostService));
const diskFileSystemProvider = this._register(new DiskFileSystemProvider(logService, nativeHostService, { enableLegacyRecursiveWatcher: this.configuration.enableLegacyRecursiveWatcher }));
fileService.registerProvider(Schemas.file, diskFileSystemProvider);

// User Data Provider
Expand Down

0 comments on commit 4211a1a

Please sign in to comment.