コード例 #1
0
 public override Task Save(FileSaveInformation fileSaveInformation)
 {
     if (!string.IsNullOrEmpty(fileSaveInformation.FileName))
     {
         AutoSave.RemoveAutoSaveFile(fileSaveInformation.FileName);
     }
     return(textEditorImpl.ViewContent.Save(fileSaveInformation));
 }
コード例 #2
0
ファイル: AutoSave.cs プロジェクト: lezeSoftware/monodevelop
        /// <summary>
        /// Loads the content from an auto save file and removes the auto save file.
        /// </summary>
        public static ITextSource LoadAndRemoveAutoSave(string fileName)
        {
            string autoSaveFileName = GetAutoSaveFileName(fileName);
            var    result           = StringTextSource.ReadFrom(autoSaveFileName);

            AutoSave.RemoveAutoSaveFile(fileName);
            return(result);
        }
コード例 #3
0
 public override Task Save()
 {
     if (!string.IsNullOrEmpty(textEditorImpl.ContentName))
     {
         AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
     }
     return(textEditorImpl.ViewContent.Save());
 }
コード例 #4
0
 protected override Task OnSave()
 {
     if (!string.IsNullOrEmpty(textEditorImpl.ContentName))
     {
         AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
     }
     return(textEditorImpl.Save(new FileSaveInformation(FilePath, Encoding)));
 }
コード例 #5
0
 void IViewContent.Save()
 {
     if (!string.IsNullOrEmpty(textEditorImpl.ContentName))
     {
         AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
     }
     textEditorImpl.Save();
 }
コード例 #6
0
 void IViewContent.Save(string fileName)
 {
     if (!string.IsNullOrEmpty(fileName))
     {
         AutoSave.RemoveAutoSaveFile(fileName);
     }
     textEditorImpl.Save(new FileSaveInformation(fileName));
 }
コード例 #7
0
 public override void DiscardChanges()
 {
     if (autoSaveTask != null)
     {
         autoSaveTask.Wait(TimeSpan.FromSeconds(5));
     }
     RemoveAutoSaveTimer();
     if (!string.IsNullOrEmpty(textEditorImpl.ContentName))
     {
         AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
     }
     textEditorImpl.ViewContent.DiscardChanges();
 }
コード例 #8
0
 protected override void OnContentNameChanged()
 {
     base.OnContentNameChanged();
     if (ContentName != textEditorImpl.ContentName && !string.IsNullOrEmpty(textEditorImpl.ContentName))
     {
         AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
     }
     textEditorImpl.ContentName = this.ContentName;
     if (this.WorkbenchWindow?.Document != null)
     {
         textEditor.InitializeExtensionChain(this.WorkbenchWindow.Document);
     }
 }
コード例 #9
0
 protected override void OnFileNameChanged()
 {
     base.OnFileNameChanged();
     if (textEditor != null)
     {
         if (FilePath != textEditorImpl.ContentName && !string.IsNullOrEmpty(textEditorImpl.ContentName))
         {
             AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
         }
         textEditor.FileName = FilePath;                 // TOTEST: VSTS #770920
         if (documentContext != null)
         {
             textEditor.InitializeExtensionChain(documentContext);
         }
         UpdateTextEditorOptions(null, null);
     }
 }
コード例 #10
0
 protected override void OnContentNameChanged()
 {
     base.OnContentNameChanged();
     if (ContentName != textEditorImpl.ContentName && !string.IsNullOrEmpty(textEditorImpl.ContentName))
     {
         AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
     }
     if (ContentName != null)             // Happens when a file is converted to an untitled file, but even in that case the text editor should be associated with the old location, otherwise typing can be messed up due to change of .editconfig settings etc.
     {
         textEditor.FileName = ContentName;
     }
     if (this.WorkbenchWindow?.Document != null)
     {
         textEditor.InitializeExtensionChain(this.WorkbenchWindow.Document);
     }
     UpdateTextEditorOptions(null, null);
 }
コード例 #11
0
        void InformAutoSave()
        {
            if (isDisposed)
            {
                return;
            }
            RemoveAutoSaveTimer();
            autoSaveTimer = GLib.Timeout.Add(500, delegate {
                if (autoSaveTask != null && !autoSaveTask.IsCompleted)
                {
                    return(false);
                }

                autoSaveTask  = AutoSave.InformAutoSaveThread(textEditor.CreateSnapshot(), textEditor.FileName, IsDirty);
                autoSaveTimer = 0;
                return(false);
            });
        }
コード例 #12
0
        protected override void OnDispose()
        {
            if (isDisposed)
            {
                return;
            }

            isDisposed = true;

            HasUnsavedChangesChanged -= TextEditorViewContent_HasUnsavedChangesChanged;

            if (textEditorImpl != null)
            {
                if (autoSaveTask != null)
                {
                    autoSaveTask.Wait(TimeSpan.FromSeconds(5));
                }
                RemoveAutoSaveTimer();
                if (!string.IsNullOrEmpty(textEditorImpl.ContentName))
                {
                    AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
                }

                EditorConfigService.RemoveEditConfigContext(textEditor.FileName).Ignore();
                textEditorImpl.DirtyChanged -= HandleDirtyChanged;
                textEditor.MimeTypeChanged  -= UpdateTextEditorOptions;
                textEditor.TextChanged      -= HandleTextChanged;
                textEditorImpl.DirtyChanged -= ViewContent_DirtyChanged;;

                DefaultSourceEditorOptions.Instance.Changed -= UpdateTextEditorOptions;
                textEditor.Dispose();
            }
            RemovePolicyChangeHandler();

            editorOptionsUpdateCancellationSource?.Cancel();

            base.OnDispose();
        }
コード例 #13
0
        protected override async void OnContentNameChanged()
        {
            base.OnContentNameChanged();
            if (ContentName != textEditorImpl.ContentName && !string.IsNullOrEmpty(textEditorImpl.ContentName))
            {
                AutoSave.RemoveAutoSaveFile(textEditorImpl.ContentName);
            }
            if (textEditorImpl.ContentName != null && textEditorImpl.ContentName != this.ContentName)
            {
                EditorConfigService.RemoveEditConfigContext(textEditorImpl.ContentName).Ignore();
                var context = await EditorConfigService.GetEditorConfigContext(textEditor.FileName, default(CancellationToken));

                if (context != null)
                {
                    ((DefaultSourceEditorOptions)textEditor.Options).SetContext(context);
                }
            }
            textEditorImpl.ContentName = this.ContentName;
            if (this.WorkbenchWindow?.Document != null)
            {
                textEditor.InitializeExtensionChain(this.WorkbenchWindow.Document);
            }
            UpdateTextEditorOptions(null, null);
        }