Skip to content

Commit

Permalink
Merge pull request #2910 from VsVim/dev/jaredpar/splitEditorUtils
Browse files Browse the repository at this point in the history
Complete the refactoring of VimEditorUtils
  • Loading branch information
jaredpar committed Jul 13, 2021
2 parents 464a322 + 6b10cbb commit b53e5d7
Show file tree
Hide file tree
Showing 86 changed files with 2,619 additions and 2,458 deletions.
5 changes: 1 addition & 4 deletions Src/VimApp/VimComponentHost.cs
Expand Up @@ -6,7 +6,6 @@
using Microsoft.VisualStudio.Text;
using Vim;
using Vim.UI.Wpf;
using Vim.UnitTest.Exports;

namespace VimApp
{
Expand All @@ -32,10 +31,8 @@ internal IVim Vim

internal VimComponentHost()
{
var editorHostFactory = new VimEditorHostFactory(includeSelf: false, includeWpf: false);
var editorHostFactory = new VimEditorHostFactory();

editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));
editorHostFactory.Add(new AssemblyCatalog(typeof(VimComponentHost).Assembly));
_editorHost = editorHostFactory.CreateVimEditorHost();
_vim = _editorHost.CompositionContainer.GetExportedValue<IVim>();
}
Expand Down
2 changes: 1 addition & 1 deletion Src/VimCore/CoreInterfaces.fs
Expand Up @@ -1913,7 +1913,7 @@ type BlockSpan =
BlockSpan(x.VirtualStart, x.TabStop, x.SpacesLength, x.Height, endOfLine)

override x.ToString() =
sprintf "Point: %s Spaces: %d Height: %d EndOfLine: %b" (x.Start.ToString()) x._spaces x._height x._endOfLine
sprintf "Line Position: (%d, %d) Spaces: %d Height: %d EndOfLine: %b" (x.Start.LineNumber) (x.Start.Offset) x._spaces x._height x._endOfLine

static member op_Equality(this,other) = System.Collections.Generic.EqualityComparer<BlockSpan>.Default.Equals(this,other)
static member op_Inequality(this,other) = not (System.Collections.Generic.EqualityComparer<BlockSpan>.Default.Equals(this,other))
Expand Down
10 changes: 8 additions & 2 deletions Src/VimCore/EditorUtil.fs
Expand Up @@ -439,7 +439,10 @@ type SnapshotCodePoint =

/// Debugger display
override x.ToString() =
sprintf "CodePoint: %s Text: %s Line: %d Offset: %d" (x.CodePointText) (x.GetText()) (x.Line.LineNumber) (x.Offset)
if x.Length = 1 then
sprintf "Character: %s Position: %d" (x.CharacterText) (x.StartPosition)
else
sprintf "Character: %s Position: [%d, %d)" (x.CharacterText) (x.StartPosition) (x.EndPosition)

override x.GetHashCode() =
HashUtil.Combine2 x.Line.LineNumber x.Offset
Expand Down Expand Up @@ -1297,7 +1300,10 @@ type SnapshotOverlapColumnSpan =
new (startColumn: SnapshotOverlapColumn, endColumn: SnapshotOverlapColumn, tabStop: int) =
let startColumn = startColumn.WithTabStop tabStop
let endColumn = endColumn.WithTabStop tabStop
if startColumn.Column.StartPosition + startColumn.SpacesBefore > endColumn.Column.StartPosition + endColumn.SpacesBefore then
if startColumn.Column = endColumn.Column then
if startColumn.Column.StartPosition + startColumn.SpacesBefore > endColumn.Column.StartPosition + endColumn.SpacesBefore then
invalidArg "endColumn" "End cannot be before the start"
if startColumn.Column.StartPosition > endColumn.Column.StartPosition then
invalidArg "endColumn" "End cannot be before the start"
{ _start = startColumn; _end = endColumn }

Expand Down
13 changes: 8 additions & 5 deletions Src/VimCore/MefComponents.fs
Expand Up @@ -487,17 +487,20 @@ type internal ProtectedOperations =
type internal VimWordCompletionSessionFactoryService
[<ImportingConstructor>]
(
_wordCompletionSessionFactory: IWordCompletionSessionFactory
[<Import(AllowDefault=true)>] _wordCompletionSessionFactory: IWordCompletionSessionFactory
) =

let _created = StandardEvent<WordCompletionSessionEventArgs>()

member x.CreateWordCompletionSession textView wordSpan words isForward =
match _wordCompletionSessionFactory.CreateWordCompletionSession textView wordSpan words isForward with
match OptionUtil.nullToOption _wordCompletionSessionFactory with
| None -> None
| Some session ->
_created.Trigger x (WordCompletionSessionEventArgs(session))
Some session
| Some factory ->
match factory.CreateWordCompletionSession textView wordSpan words isForward with
| None -> None
| Some session ->
_created.Trigger x (WordCompletionSessionEventArgs(session))
Some session

interface IWordCompletionSessionFactoryService with
member x.CreateWordCompletionSession textView wordSpan words isForward = x.CreateWordCompletionSession textView wordSpan words isForward
Expand Down

0 comments on commit b53e5d7

Please sign in to comment.