diff --git a/main/msbuild/ReferencesVSEditor.Windows.props b/main/msbuild/ReferencesVSEditor.Windows.props index f556230002d..fd4895e0de7 100644 --- a/main/msbuild/ReferencesVSEditor.Windows.props +++ b/main/msbuild/ReferencesVSEditor.Windows.props @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs index bf0d3cbef83..3fd8c234baf 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs @@ -47,7 +47,7 @@ using Roslyn.Utilities; using Microsoft.CodeAnalysis.Options; using MonoDevelop.CSharp.OptionProvider; -using Microsoft.VisualStudio.CodingConventions; +//using Microsoft.VisualStudio.CodingConventions; using System.Linq; using System.Collections.Immutable; using System.Runtime.CompilerServices; @@ -143,7 +143,7 @@ protected override ITextSource FormatImplementation (PolicyContainer policyParen var textPolicy = policyParent.Get (chain); var optionSet = policy.CreateOptions (textPolicy); - if (input is IReadonlyTextDocument doc) { + /* if (input is IReadonlyTextDocument doc) { try { var conventions = EditorConfigService.GetEditorConfigContext (doc.FileName).WaitAndGetResult (); if (conventions != null) @@ -151,12 +151,12 @@ protected override ITextSource FormatImplementation (PolicyContainer policyParen } catch (Exception e) { LoggingService.LogError ("Error while loading coding conventions.", e); } - } + } */ return new StringTextSource (FormatText (optionSet, input.Text, startOffset, startOffset + length)); } - sealed class DocumentOptions : IDocumentOptions + /* sealed class DocumentOptions : IDocumentOptions { readonly OptionSet optionSet; readonly ICodingConventionsSnapshot codingConventionsSnapshot; @@ -164,13 +164,13 @@ sealed class DocumentOptions : IDocumentOptions new ConditionalWeakTable, IReadOnlyDictionary> (); - public DocumentOptions (OptionSet optionSet, ICodingConventionsSnapshot codingConventionsSnapshot) + public DocumentOptions (OptionSet optionSet, ICodingConventionsSnapshot codingConventionsSnapshot) { this.optionSet = optionSet; this.codingConventionsSnapshot = codingConventionsSnapshot; } - public bool TryGetDocumentOption (OptionKey option, out object value) + public bool TryGetDocumentOption (OptionKey option, out object value) { if (codingConventionsSnapshot != null) { var editorConfigPersistence = option.Option.StorageLocations.OfType ().SingleOrDefault (); @@ -198,8 +198,8 @@ public bool TryGetDocumentOption (OptionKey option, out object value) var result = optionSet.GetOption (option); value = result; return true; - } - } + } + } */ sealed class FormattingDocumentOptionSet : OptionSet { diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs index b48aca4ce4c..63477e3126c 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/CSharpDocumentOptionsProvider.cs @@ -23,7 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System; +/* using System; using System.ComponentModel.Composition; using System.Threading; using System.Threading.Tasks; @@ -54,12 +54,12 @@ async Task IDocumentOptionsProvider.GetOptionsForDocumentAsync var path = GetPath (document); ICodingConventionContext conventions = null; - try { - if (path != null) - conventions = await EditorConfigService.GetEditorConfigContext (path, cancellationToken); - } catch (Exception e) { - LoggingService.LogError("Error while loading coding conventions.", e); - } + try { + if (path != null) + //conventions = await EditorConfigService.GetEditorConfigContext (path, cancellationToken); + } catch (Exception e) { + LoggingService.LogError("Error while loading coding conventions.", e); + } return new DocumentOptions (project?.Policies, conventions?.CurrentConventions); } @@ -155,3 +155,4 @@ public bool TryGetDocumentOption (OptionKey option, out object value) } } } + */ \ No newline at end of file diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/OptionProviderFactory.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/OptionProviderFactory.cs index b10358ea09b..2a01af55155 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/OptionProviderFactory.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.OptionProvider/OptionProviderFactory.cs @@ -23,7 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System; +/* using System; using System.ComponentModel.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Options; @@ -39,3 +39,4 @@ public IDocumentOptionsProvider TryCreate (Workspace workspace) } } } + */ \ No newline at end of file diff --git a/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs b/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs index 29c89bce8ff..fd7d3af5782 100644 --- a/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs +++ b/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs @@ -32,7 +32,7 @@ using Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods; using Microsoft.VisualStudio.Text.Utilities; -using Microsoft.VisualStudio.CodingConventions; +//using Microsoft.VisualStudio.CodingConventions; using Microsoft.VisualStudio.Threading; using Microsoft.VisualStudio.Utilities; @@ -49,7 +49,7 @@ using MonoDevelop.Ide.Gui.Documents; using AutoSave = MonoDevelop.Ide.Editor.AutoSave; -using EditorConfigService = MonoDevelop.Ide.Editor.EditorConfigService; +//using EditorConfigService = MonoDevelop.Ide.Editor.EditorConfigService; using DefaultSourceEditorOptions = MonoDevelop.Ide.Editor.DefaultSourceEditorOptions; using MonoDevelop.Components; using System.Threading; @@ -86,7 +86,7 @@ abstract partial class TextViewContent : static bool settingZoomLevel; PolicyContainer policyContainer; - ICodingConventionContext editorConfigContext; + //ICodingConventionContext editorConfigContext; bool warnOverwrite; IDisposable textBufferRegistration; @@ -161,7 +161,7 @@ protected override async Task OnGetViewControlAsync (CancellationToken EditorOperations = (EditorOperationsInterface)Imports.EditorOperationsProvider.GetEditorOperations (TextView); EditorOptions = Imports.EditorOptionsFactoryService.GetOptions (TextView); TextBufferOptions = Imports.EditorOptionsFactoryService.GetOptions (TextView.TextBuffer); - UpdateTextEditorOptions (this, EventArgs.Empty); + //UpdateTextEditorOptions (this, EventArgs.Empty); contentProviders = new List (Imports.EditorContentProviderService.GetContentProvidersForView (TextView)); TextView.Properties [typeof (DocumentController)] = this; @@ -199,7 +199,7 @@ protected override async Task OnGetViewControlAsync (CancellationToken // Content providers can provide additional content NotifyContentChanged (); - await Load (false); + ////await Load (false); return control; } @@ -249,11 +249,11 @@ protected override void OnFileNameChanged () warnOverwrite = false; - if (editorConfigContext != null) { + /* if (editorConfigContext != null) { editorConfigContext.CodingConventionsChangedAsync -= UpdateOptionsFromEditorConfigAsync; EditorConfigService.RemoveEditConfigContext (TextDocument.FilePath).Ignore (); editorConfigContext = null; - } + } */ if (FilePath != TextDocument.FilePath && !string.IsNullOrEmpty (TextDocument.FilePath)) AutoSave.RemoveAutoSaveFile (TextDocument.FilePath); @@ -272,7 +272,7 @@ protected override void OnFileNameChanged () UpdateTextBufferRegistration (); - UpdateTextEditorOptions (null, null); + //UpdateTextEditorOptions (null, null); } protected override void OnOwnerChanged () @@ -280,7 +280,7 @@ protected override void OnOwnerChanged () base.OnOwnerChanged (); if (TextDocument != null) { - UpdateTextEditorOptions (null, null); + //UpdateTextEditorOptions (null, null); UpdateTextBufferRegistration (); } } @@ -312,19 +312,19 @@ protected override void OnDispose () UnsubscribeFromEvents (); - if (policyContainer != null) + /* if (policyContainer != null) policyContainer.PolicyChanged -= PolicyChanged; if (editorConfigContext != null) { editorConfigContext.CodingConventionsChangedAsync -= UpdateOptionsFromEditorConfigAsync; EditorConfigService.RemoveEditConfigContext (FilePath).Ignore (); - } + } */ base.OnDispose (); } protected virtual void SubscribeToEvents () { - sourceEditorOptions.Changed += UpdateTextEditorOptions; + //sourceEditorOptions.Changed += UpdateTextEditorOptions; TextDocument.DirtyStateChanged += HandleTextDocumentDirtyStateChanged; TextBuffer.Changed += HandleTextBufferChanged; TextView.Options.OptionChanged += TextBufferOptionsChanged; @@ -332,8 +332,8 @@ protected virtual void SubscribeToEvents () protected virtual void UnsubscribeFromEvents () { - if (sourceEditorOptions != null) - sourceEditorOptions.Changed -= UpdateTextEditorOptions; + // if (sourceEditorOptions != null) + // sourceEditorOptions.Changed -= UpdateTextEditorOptions; if (TextDocument != null) TextDocument.DirtyStateChanged -= HandleTextDocumentDirtyStateChanged; @@ -362,7 +362,7 @@ void UpdateLineNumberMarginOption () sourceEditorOptions.ShowLineNumberMargin); } - void UpdateTextEditorOptions (object sender, EventArgs e) + /* void UpdateTextEditorOptions (object sender, EventArgs e) { UpdateTextEditorOptionsAsync ().Forget (); } @@ -393,7 +393,7 @@ async Task UpdateTextEditorOptionsAsync () editorConfigContext.CodingConventionsChangedAsync += UpdateOptionsFromEditorConfigAsync; await UpdateOptionsFromEditorConfigAsync (null, null); - } + } */ void ClearOptionValue(string optionName) { @@ -438,7 +438,7 @@ private void UpdateOptionsFromPolicy() #endif } - private Task UpdateOptionsFromEditorConfigAsync (object sender, CodingConventionsChangedEventArgs args) +/* private Task UpdateOptionsFromEditorConfigAsync (object sender, CodingConventionsChangedEventArgs args) { // Set base options first, then override with editorconfig values UpdateOptionsFromPolicy (); @@ -610,7 +610,7 @@ void UseOriginalFile () } return Task.CompletedTask; - } + } */ /// /// Replace document content with new content. This marks the document as dirty. @@ -779,7 +779,7 @@ void ReloadFromDisk () if (IsDisposed || !File.Exists (FilePath)) return; - Load (true); + ////Load (true); ShowNotification = false; } catch (Exception ex) { MessageService.ShowError ("Could not reload the file.", ex); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj index 4ed1e937e1a..be0a7ca1a9b 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj @@ -88,7 +88,7 @@ - + @@ -127,7 +127,7 @@ - + @@ -137,7 +137,7 @@ - + diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml index cacaf7a52cc..878a0fe7820 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml @@ -1,6 +1,6 @@ - + @@ -431,7 +431,7 @@ - + diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs index 53745babf69..6ea93638517 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/DefaultSourceEditorOptions.cs @@ -28,7 +28,7 @@ using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.Fonts; using MonoDevelop.Ide.Editor.Extension; -using Microsoft.VisualStudio.CodingConventions; +//using Microsoft.VisualStudio.CodingConventions; using System.Threading.Tasks; using MonoDevelop.Ide.TypeSystem; @@ -58,7 +58,7 @@ public sealed class DefaultSourceEditorOptions : ITextEditorOptions static DefaultSourceEditorOptions instance; static ITextEditorOptions plainEditor; static bool inited; - ICodingConventionContext context; + //ICodingConventionContext context; public static DefaultSourceEditorOptions Instance { get { @@ -187,8 +187,8 @@ bool ITextEditorOptions.RemoveTrailingWhitespaces { get { return DefaultSourceEditorOptions.Instance.RemoveTrailingWhitespaces; } - } - + } + [Obsolete ("Old editor")] bool ITextEditorOptions.WrapLines { get { @@ -277,13 +277,13 @@ void HandlePolicyChanged (object sender, MonoDevelop.Projects.Policies.PolicyCha }); IdeApp.Preferences.ColorScheme.Changed += OnColorSchemeChanged; - IdeApp.Preferences.Editor.FollowCodingConventions.Changed += OnFollowCodingConventionsChanged; + //IdeApp.Preferences.Editor.FollowCodingConventions.Changed += OnFollowCodingConventionsChanged; } - void OnFollowCodingConventionsChanged (object sender, EventArgs e) + /* void OnFollowCodingConventionsChanged (object sender, EventArgs e) { UpdateContextOptions (null, null).Ignore (); - } + } */ void UpdateFont () @@ -319,7 +319,7 @@ public DefaultSourceEditorOptions WithTextStyle (TextStylePolicy policy) return result; } - internal void SetContext (ICodingConventionContext context) + /* internal void SetContext (ICodingConventionContext context) { if (this.context == context) return; @@ -342,8 +342,8 @@ private Task UpdateContextOptions (object sender, CodingConventionsChangedEventA defaultEolMarkerFromContext = eolMarker; tabsToSpacesFromContext = null; - if (followCodingConventions && context.CurrentConventions.UniversalConventions.TryGetIndentStyle (out Microsoft.VisualStudio.CodingConventions.IndentStyle result)) - tabsToSpacesFromContext = result == Microsoft.VisualStudio.CodingConventions.IndentStyle.Spaces; + //if (followCodingConventions && context.CurrentConventions.UniversalConventions.TryGetIndentStyle (out Microsoft.VisualStudio.CodingConventions.IndentStyle result)) + // tabsToSpacesFromContext = result == Microsoft.VisualStudio.CodingConventions.IndentStyle.Spaces; indentationSizeFromContext = null; if (followCodingConventions && context.CurrentConventions.UniversalConventions.TryGetIndentSize (out int indentSize)) @@ -369,7 +369,7 @@ private Task UpdateContextOptions (object sender, CodingConventionsChangedEventA } this.FireChange (); return Task.CompletedTask; - } + } */ #region new options @@ -931,12 +931,13 @@ public bool SmartBackspace{ public void Dispose () { - IdeServices.FontService.RemoveCallback (UpdateFont); + /* IdeServices.FontService.RemoveCallback (UpdateFont); IdeApp.Preferences.ColorScheme.Changed -= OnColorSchemeChanged; IdeApp.Preferences.Editor.FollowCodingConventions.Changed -= OnFollowCodingConventionsChanged; if (context != null) - context.CodingConventionsChangedAsync -= UpdateContextOptions; - } + context.CodingConventionsChangedAsync -= UpdateContextOptions; */ + + } void OnChanged (EventArgs args) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs index cfbe6a55127..d904cc5a5c1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditorConfigService.cs @@ -23,7 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System; +/* using System; using System.Collections.Immutable; using System.IO; using System.Linq; @@ -44,7 +44,7 @@ static class EditorConfigService readonly static object contextCacheLock = new object (); readonly static ICodingConventionsManager codingConventionsManager = CodingConventionsManagerFactory.CreateCodingConventionsManager (new ConventionsFileManager()); static ImmutableDictionary contextCache = ImmutableDictionary.Empty; - + public static class GetEditorConfigContext (string fileName, CancellationToken token = default (CancellationToken)) public static async Task GetEditorConfigContext (string fileName, CancellationToken token = default (CancellationToken)) { if (string.IsNullOrEmpty (fileName)) @@ -87,112 +87,113 @@ static class EditorConfigService public static Task RemoveEditConfigContext (string fileName) { - return Task.Run (() => { - ICodingConventionContext ctx; - lock (contextCacheLock) { - if (!contextCache.TryGetValue (fileName, out ctx)) - return; - contextCache = contextCache.Remove (fileName); - } - if (ctx != null) + return Task.Run (() => { + ICodingConventionContext ctx; + lock (contextCacheLock) { + if (!contextCache.TryGetValue (fileName, out ctx)) + return; + contextCache = contextCache.Remove (fileName); + } + if (ctx != null) ctx.Dispose (); }); } - class ConventionsFileManager : IFileWatcher - { - HashSet watchedFiles = new HashSet (); + class ConventionsFileManager : IFileWatcher + { + HashSet watchedFiles = new HashSet (); public event ConventionsFileChangedAsyncEventHandler ConventionFileChanged; - public event ContextFileMovedAsyncEventHandler ContextFileMoved; - - public ConventionsFileManager () - { - FileService.FileChanged += FileService_FileChanged; - FileService.FileRemoved += FileService_FileRemoved; - FileService.FileMoved += FileService_FileMoved; - FileService.FileRenamed += FileService_FileMoved; - } - - void FileService_FileMoved (object sender, FileCopyEventArgs e) - { - lock (watchedFiles) { - foreach (var file in e) { - if (watchedFiles.Remove (file.SourceFile)) { - ContextFileMoved?.Invoke (this, new ContextFileMovedEventArgs (file.SourceFile, file.TargetFile)); - if (file.SourceFile == file.TargetFile) { - StartWatching (file.TargetFile.FileName, file.TargetFile.ParentDirectory); - } - } - } - } - } - - void FileService_FileChanged (object sender, FileEventArgs e) - { - lock (watchedFiles) { - foreach (var file in e) { - if (watchedFiles.Contains (file.FileName)) { - ConventionFileChanged?.Invoke (this, new ConventionsFileChangeEventArgs (file.FileName.FileName, file.FileName.ParentDirectory, ChangeType.FileModified)); - } - } - } - } - - void FileService_FileRemoved (object sender, FileEventArgs e) - { - lock (watchedFiles) { - foreach (var file in e) { - if (watchedFiles.Remove (file.FileName)) { - ConventionFileChanged?.Invoke (this, new ConventionsFileChangeEventArgs (file.FileName.FileName, file.FileName.ParentDirectory, ChangeType.FileDeleted)); - WatchDirectories (); - } - } - } - } - - public void Dispose () - { - FileService.FileMoved -= FileService_FileMoved; - FileService.FileRenamed -= FileService_FileMoved; - FileService.FileRemoved -= FileService_FileRemoved; - FileService.FileChanged -= FileService_FileChanged; - FileWatcherService.WatchDirectories (this, null).Ignore (); - lock (watchedFiles) { - watchedFiles = null; - } - } - - public void StartWatching (string fileName, string directoryPath) - { - lock (watchedFiles) { - var key = directoryPath + Path.DirectorySeparatorChar.ToString () + fileName; - - if (!File.Exists (key)) - return; - - if (!watchedFiles.Add (key)) - return; - - WatchDirectories (); - } - } - - public void StopWatching (string fileName, string directoryPath) - { - lock (watchedFiles) { - var key = directoryPath + Path.DirectorySeparatorChar.ToString () + fileName; - if (watchedFiles.Remove (key)) { - WatchDirectories (); - } - } - } - - void WatchDirectories () - { - var directories = watchedFiles.Count == 0 ? null : watchedFiles.Select (file => new FilePath (file).ParentDirectory); - FileWatcherService.WatchDirectories (this, directories).Ignore (); - } - } + public event ContextFileMovedAsyncEventHandler ContextFileMoved; + + public ConventionsFileManager () + { + FileService.FileChanged += FileService_FileChanged; + FileService.FileRemoved += FileService_FileRemoved; + FileService.FileMoved += FileService_FileMoved; + FileService.FileRenamed += FileService_FileMoved; + } + + void FileService_FileMoved (object sender, FileCopyEventArgs e) + { + lock (watchedFiles) { + foreach (var file in e) { + if (watchedFiles.Remove (file.SourceFile)) { + ContextFileMoved?.Invoke (this, new ContextFileMovedEventArgs (file.SourceFile, file.TargetFile)); + if (file.SourceFile == file.TargetFile) { + StartWatching (file.TargetFile.FileName, file.TargetFile.ParentDirectory); + } + } + } + } + } + + void FileService_FileChanged (object sender, FileEventArgs e) + { + lock (watchedFiles) { + foreach (var file in e) { + if (watchedFiles.Contains (file.FileName)) { + ConventionFileChanged?.Invoke (this, new ConventionsFileChangeEventArgs (file.FileName.FileName, file.FileName.ParentDirectory, ChangeType.FileModified)); + } + } + } + } + + void FileService_FileRemoved (object sender, FileEventArgs e) + { + lock (watchedFiles) { + foreach (var file in e) { + if (watchedFiles.Remove (file.FileName)) { + ConventionFileChanged?.Invoke (this, new ConventionsFileChangeEventArgs (file.FileName.FileName, file.FileName.ParentDirectory, ChangeType.FileDeleted)); + WatchDirectories (); + } + } + } + } + + public void Dispose () + { + FileService.FileMoved -= FileService_FileMoved; + FileService.FileRenamed -= FileService_FileMoved; + FileService.FileRemoved -= FileService_FileRemoved; + FileService.FileChanged -= FileService_FileChanged; + FileWatcherService.WatchDirectories (this, null).Ignore (); + lock (watchedFiles) { + watchedFiles = null; + } + } + + public void StartWatching (string fileName, string directoryPath) + { + lock (watchedFiles) { + var key = directoryPath + Path.DirectorySeparatorChar.ToString () + fileName; + + if (!File.Exists (key)) + return; + + if (!watchedFiles.Add (key)) + return; + + WatchDirectories (); + } + } + + public void StopWatching (string fileName, string directoryPath) + { + lock (watchedFiles) { + + var key = directoryPath + Path.DirectorySeparatorChar.ToString () + fileName; + if (watchedFiles.Remove (key)) { + WatchDirectories (); + } + } + } + + void WatchDirectories () + { + var directories = watchedFiles.Count == 0 ? null : watchedFiles.Select (file => new FilePath (file).ParentDirectory); + FileWatcherService.WatchDirectories (this, directories).Ignore (); + } + } } -} +} */ diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs index aeeb4f2e1a8..c96955a0475 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs @@ -1071,18 +1071,18 @@ void TextEditor_ZoomLevelChanged (object sender, EventArgs e) async void TextEditor_FileNameChanged (object sender, EventArgs e) { - fileTypeCondition.SetFileName (FileName); + //fileTypeCondition.SetFileName (FileName); // This is a sync call to remove from the cache, then async to dispose the context after the load is awaited. - EditorConfigService.RemoveEditConfigContext (FileName).Ignore (); + //EditorConfigService.RemoveEditConfigContext (FileName).Ignore (); // There is no use to try and create a cached context if we won't use it. - if (!(Options is DefaultSourceEditorOptions options)) - return; + //if (!(Options is DefaultSourceEditorOptions options)) + // return; - var context = await EditorConfigService.GetEditorConfigContext (FileName); - if (context != null) - options.SetContext (context); + //var context = await EditorConfigService.GetEditorConfigContext (FileName); + //if (context != null) + // options.SetContext (context); } void TextEditor_MimeTypeChanged (object sender, EventArgs e) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs index b262e0c3cfd..472a9e8f3ca 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditorViewContent.cs @@ -236,10 +236,10 @@ async Task UpdateStyleParent (WorkspaceObject owner, string mimeType, Cancellati policyContainer.PolicyChanged += HandlePolicyChanged; ((DefaultSourceEditorOptions)textEditor.Options).UpdateStylePolicy (currentPolicy); - var context = await EditorConfigService.GetEditorConfigContext (textEditor.FileName, token); - if (context == null) - return; - ((DefaultSourceEditorOptions)textEditor.Options).SetContext (context); + //var context = await EditorConfigService.GetEditorConfigContext (textEditor.FileName, token); + //if (context == null) + // return; + // ((DefaultSourceEditorOptions)textEditor.Options).SetContext (context); } void HandlePolicyChanged (object sender, MonoDevelop.Projects.Policies.PolicyChangedEventArgs args) @@ -325,8 +325,8 @@ internal protected override ProjectReloadCapability OnGetProjectReloadCapability protected override IEnumerable OnGetContents (Type type) { foreach (var r in base.OnGetContents (type)) - yield return r; - + yield return r; + if (textEditorImpl != null) { if (type == typeof(ITextBuffer)) { yield return textEditor.TextView.TextBuffer; @@ -379,7 +379,7 @@ protected override void OnDispose () if (!string.IsNullOrEmpty (textEditorImpl.ContentName)) AutoSave.RemoveAutoSaveFile (textEditorImpl.ContentName); - EditorConfigService.RemoveEditConfigContext (textEditor.FileName).Ignore (); + //EditorConfigService.RemoveEditConfigContext (textEditor.FileName).Ignore (); textEditorImpl.DirtyChanged -= HandleDirtyChanged; textEditor.MimeTypeChanged -= UpdateTextEditorOptions; textEditor.TextChanged -= HandleTextChanged; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs index 80334f39e95..050293e6762 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs @@ -482,12 +482,12 @@ public virtual async Task CreateFileContentAsync (SolutionFolderItem pol : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy (mime ?? "text/plain"); string eolMarker = TextStylePolicy.GetEolMarker (textPolicy.EolMarker); - var ctx = await EditorConfigService.GetEditorConfigContext (fileName); + /* var ctx = await EditorConfigService.GetEditorConfigContext (fileName); if (ctx != null) { ctx.CurrentConventions.UniversalConventions.TryGetEncoding (out encoding); if (ctx.CurrentConventions.UniversalConventions.TryGetLineEnding (out string lineEnding)) eolMarker = lineEnding; - } + } */ if (encoding == null) encoding = System.Text.Encoding.UTF8; var bom = encoding.GetPreamble (); @@ -509,12 +509,12 @@ public virtual async Task CreateFileContentAsync (SolutionFolderItem pol bool convertTabsToSpaces = textPolicy.TabsToSpaces; int tabWidth = textPolicy.TabWidth; - if (ctx != null) { + /* if (ctx != null) { if (ctx.CurrentConventions.UniversalConventions.TryGetIndentStyle (out Microsoft.VisualStudio.CodingConventions.IndentStyle result)) convertTabsToSpaces = result == Microsoft.VisualStudio.CodingConventions.IndentStyle.Spaces; if (ctx.CurrentConventions.UniversalConventions.TryGetTabWidth (out int editorConfigTabWidth)) tabWidth = editorConfigTabWidth; - } + } */ var tabToSpaces = convertTabsToSpaces ? new string (' ', tabWidth) : null; IDocumentLine lastLine = null; @@ -529,13 +529,13 @@ public virtual async Task CreateFileContentAsync (SolutionFolderItem pol } lastLine = line; } - if (ctx != null && lastLine != null && lastLine.Length > 0) { + /* if (ctx != null && lastLine != null && lastLine.Length > 0) { if (ctx.CurrentConventions.UniversalConventions.TryGetRequireFinalNewline (out bool requireNewLine)) { if (requireNewLine) ms.Write (eolMarkerBytes, 0, eolMarkerBytes.Length); } } - ctx.Dispose (); + ctx.Dispose (); */ ms.Position = 0; return ms; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 9329838e2c6..624216a93c1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -55,8 +55,9 @@ - + + diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/EditorConfigTests.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/EditorConfigTests.cs index 10094a00f96..a01fdac83ae 100644 --- a/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/EditorConfigTests.cs +++ b/main/tests/Ide.Tests/MonoDevelop.Ide.Editor/EditorConfigTests.cs @@ -24,7 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System.IO; +/* using System.IO; using NUnit.Framework; using UnitTests; using System.Threading; @@ -186,3 +186,4 @@ await InvokeEditConfigTest (@" } } + */ \ No newline at end of file