Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor/Text/Impl/EditorOperations/EditorOperations.cs')
-rw-r--r--src/Editor/Text/Impl/EditorOperations/EditorOperations.cs82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs b/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs
index 3f6107d..3a2c915 100644
--- a/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs
+++ b/src/Editor/Text/Impl/EditorOperations/EditorOperations.cs
@@ -27,6 +27,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Language.Intellisense.Utilities;
using Microsoft.VisualStudio.Text.Utilities;
+ using Microsoft.VisualStudio.Text.Data.Utilities;
/// <summary>
/// Provides a default operations set on top of the text editor
@@ -56,7 +57,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
#region Private Members
- readonly ITextView3 _textView;
+ readonly ITextView _textView;
readonly EditorOperationsFactoryService _factory;
readonly ITextDocument _textDocument;
readonly ITextStructureNavigator _textStructureNavigator;
@@ -96,7 +97,7 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
if (factory == null)
throw new ArgumentNullException(nameof(factory));
- _textView = (Microsoft.VisualStudio.Text.Editor.ITextView3) textView;
+ _textView = textView;
_factory = factory;
_multiSelectionBroker = _textView.GetMultiSelectionBroker();
_editorPrimitives = factory.EditorPrimitivesProvider.GetViewPrimitives(textView);
@@ -3188,14 +3189,20 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
public void ScrollColumnLeft()
{
- // A column is defined as the width of a space in the default font
- _textView.ViewScroller.ScrollViewportHorizontallyByPixels(_textView.FormattedLineSource.ColumnWidth * -1.0);
+ if (_textView.ViewScroller is IViewScroller2 viewScroller)
+ {
+ // A column is defined as the width of a space in the default font
+ viewScroller.ScrollColumnLeft();
+ }
}
public void ScrollColumnRight()
{
- // A column is defined as the width of a space in the default font
- _textView.ViewScroller.ScrollViewportHorizontallyByPixels(_textView.FormattedLineSource.ColumnWidth);
+ if (_textView.ViewScroller is IViewScroller2 viewScroller)
+ {
+ // A column is defined as the width of a space in the default font
+ viewScroller.ScrollColumnRight();
+ }
}
public void ScrollLineBottom()
@@ -3229,54 +3236,35 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
_undoHistory.CurrentTransaction.AddUndo(beforeTextBufferChangeUndoPrimitive);
}
- public bool CanZoomIn => CanZoomTo && _textView.ZoomLevel < _textView.Options.GlobalOptions.MaxZoom();
+ public bool CanZoomIn => CanZoomTo && _factory.ZoomManager.ZoomLevel(_textView) < _textView.Options.GlobalOptions.MaxZoom();
- public void ZoomIn()
- {
- if (CanZoomIn)
- {
- var maxZoom = _textView.Options.GlobalOptions.MaxZoom();
- double zoomLevel = Math.Min(_textView.ZoomLevel * ZoomConstants.ScalingFactor, maxZoom);
- if (zoomLevel < maxZoom || Math.Abs(zoomLevel - maxZoom) < 0.00001)
- {
- _textView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel);
- }
- }
- }
+ public bool CanZoomOut => CanZoomTo && _factory.ZoomManager.ZoomLevel(_textView) > _textView.Options.GlobalOptions.MinZoom();
- public bool CanZoomOut => CanZoomTo && _textView.ZoomLevel > _textView.Options.GlobalOptions.MinZoom();
+ public bool CanZoomTo => _textView.Roles.Contains(PredefinedTextViewRoles.Zoomable);
- public void ZoomOut()
+ public bool CanZoomReset => CanZoomTo && _factory.ZoomManager.ZoomLevel(_textView) != ZoomConstants.DefaultZoom;
+
+ public void ZoomReset()
{
- if (CanZoomOut)
+ if (CanZoomReset)
{
- var minZoom = _textView.Options.GlobalOptions.MinZoom();
- double zoomLevel = Math.Max(_textView.ZoomLevel / ZoomConstants.ScalingFactor, minZoom);
- if (zoomLevel > minZoom || Math.Abs(zoomLevel - minZoom) < 0.00001)
- {
- _textView.Options.GlobalOptions.SetOptionValue(DefaultTextViewOptions.ZoomLevelId, zoomLevel);
- }
+ ZoomTo(ZoomConstants.DefaultZoom);
}
}
- public bool CanZoomTo => _textView.Roles.Contains(PredefinedTextViewRoles.Zoomable);
-
- public void ZoomTo(double zoomLevel)
+ public void ZoomIn()
{
- if (CanZoomTo)
- {
- _textView.Options.GlobalOptions.SetZoomLevel(zoomLevel);
- }
+ _factory.ZoomManager.ZoomIn(_textView);
}
- public bool CanZoomReset => CanZoomTo && _textView.ZoomLevel != ZoomConstants.DefaultZoom;
+ public void ZoomOut()
+ {
+ _factory.ZoomManager.ZoomOut(_textView);
+ }
- public void ZoomReset()
+ public void ZoomTo(double zoomLevel)
{
- if (CanZoomReset)
- {
- ZoomTo(ZoomConstants.DefaultZoom);
- }
+ _factory.ZoomManager.ZoomTo(_textView, zoomLevel);
}
#endregion // IEditorOperations Members
@@ -5350,6 +5338,18 @@ namespace Microsoft.VisualStudio.Text.Operations.Implementation
});
}
}
+
+ public string NormalizeNewlinesInString(string text)
+ {
+ if (_factory.WhitespaceManagerFactory.TryGetExistingWhitespaceManager(_textView.TextDataModel.DocumentBuffer, out var whitespaceManager))
+ {
+ return whitespaceManager.NewlineState.NormalizeNewlines(text);
+ }
+ else
+ {
+ return text;
+ }
+ }
}
/// <summary>