Skip to content

Commit

Permalink
Convert to return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentkempe committed Aug 25, 2018
1 parent 1e6cea5 commit 5980b7a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 80 deletions.
9 changes: 5 additions & 4 deletions GitDiffMargin.Commands/ShimCommandHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Commanding;
using Microsoft.VisualStudio.OLE.Interop;
Expand Down Expand Up @@ -28,9 +28,10 @@ public virtual CommandState GetCommandState(T args)
ErrorHandler.ThrowOnFailure(GetCommandTarget(args).QueryStatus(_commandSet, 1, command, IntPtr.Zero));
if ((command[0].cmdf & (uint) OLECMDF.OLECMDF_SUPPORTED) == 0)
return CommandState.Unspecified;
if ((command[0].cmdf & (uint) OLECMDF.OLECMDF_ENABLED) == 0)
return CommandState.Unavailable;
return CommandState.Available;

return (command[0].cmdf & (uint) OLECMDF.OLECMDF_ENABLED) == 0
? CommandState.Unavailable
: CommandState.Available;

This comment has been minimized.

Copy link
@sharwell

sharwell Aug 25, 2018

Collaborator

💭 this isn't wrong, but it's also not better IMO

}

public virtual bool ExecuteCommand(T args, CommandExecutionContext executionContext)
Expand Down
78 changes: 18 additions & 60 deletions GitDiffMargin/Core/MarginCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,71 +68,29 @@ public void Dispose()

public IGitCommands GitCommands { get; }

public FontFamily FontFamily
{
get
{
if (_classificationFormatMap.DefaultTextProperties.TypefaceEmpty)
return new FontFamily("Consolas");

return _classificationFormatMap.DefaultTextProperties.Typeface.FontFamily;
}
}

public FontStretch FontStretch
{
get
{
if (_classificationFormatMap.DefaultTextProperties.TypefaceEmpty)
return FontStretches.Normal;

return _classificationFormatMap.DefaultTextProperties.Typeface.Stretch;
}
}

public FontStyle FontStyle
{
get
{
if (_classificationFormatMap.DefaultTextProperties.TypefaceEmpty)
return FontStyles.Normal;

return _classificationFormatMap.DefaultTextProperties.Typeface.Style;
}
}
public FontFamily FontFamily => _classificationFormatMap.DefaultTextProperties.TypefaceEmpty
? new FontFamily("Consolas")
: _classificationFormatMap.DefaultTextProperties.Typeface.FontFamily;

public FontWeight FontWeight
{
get
{
if (_classificationFormatMap.DefaultTextProperties.TypefaceEmpty)
return FontWeights.Normal;
public FontStretch FontStretch => _classificationFormatMap.DefaultTextProperties.TypefaceEmpty
? FontStretches.Normal
: _classificationFormatMap.DefaultTextProperties.Typeface.Stretch;

return _classificationFormatMap.DefaultTextProperties.Typeface.Weight;
}
}

public double FontSize
{
get
{
if (_classificationFormatMap.DefaultTextProperties.FontRenderingEmSizeEmpty)
return 12.0;
public FontStyle FontStyle => _classificationFormatMap.DefaultTextProperties.TypefaceEmpty
? FontStyles.Normal
: _classificationFormatMap.DefaultTextProperties.Typeface.Style;

return _classificationFormatMap.DefaultTextProperties.FontRenderingEmSize;
}
}
public FontWeight FontWeight => _classificationFormatMap.DefaultTextProperties.TypefaceEmpty
? FontWeights.Normal
: _classificationFormatMap.DefaultTextProperties.Typeface.Weight;

public Brush Background
{
get
{
if (_classificationFormatMap.DefaultTextProperties.BackgroundBrushEmpty)
return TextView.Background;
public double FontSize => _classificationFormatMap.DefaultTextProperties.FontRenderingEmSizeEmpty
? 12.0
: _classificationFormatMap.DefaultTextProperties.FontRenderingEmSize;

return _classificationFormatMap.DefaultTextProperties.BackgroundBrush;
}
}
public Brush Background => _classificationFormatMap.DefaultTextProperties.BackgroundBrushEmpty
? TextView.Background
: _classificationFormatMap.DefaultTextProperties.BackgroundBrush;

public Brush Foreground
{
Expand Down
6 changes: 2 additions & 4 deletions GitDiffMargin/EditorDiffMarginFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#region using
#region using

using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text.Editor;
Expand All @@ -20,10 +20,8 @@ public override IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost,
IWpfTextViewMargin containerMargin)
{
var marginCore = TryGetMarginCore(textViewHost);
if (marginCore == null)
return null;

return new EditorDiffMargin(textViewHost.TextView, marginCore);
return marginCore == null ? null : new EditorDiffMargin(textViewHost.TextView, marginCore);
}
}
}
8 changes: 4 additions & 4 deletions GitDiffMargin/Git/GitCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ public void StartExternalDiff(ITextDocument textDocument, string originalPath)
{
// determine if the file has been staged
var stagedMask = FileStatus.NewInIndex | FileStatus.ModifiedInIndex;
var revision = (repo.RetrieveStatus(relativePath) & stagedMask) != 0 ? "index" : repo.Head.Tip.Sha.Substring(0, 7);
var revision = (repo.RetrieveStatus(relativePath) & stagedMask) != 0
? "index"
: repo.Head.Tip.Sha.Substring(0, 7);

leftLabel = string.Format("{0}@{1}", objectName, revision);
}
Expand Down Expand Up @@ -232,10 +234,8 @@ public string GetGitWorkingCopy(string path, string originalPath)
using (var repository = new Repository(repositoryPath))
{
var workingDirectory = repository.Info.WorkingDirectory;
if (workingDirectory == null)
return null;

return Path.GetFullPath(workingDirectory);
return workingDirectory == null ? null : Path.GetFullPath(workingDirectory);
}
}

Expand Down
6 changes: 2 additions & 4 deletions GitDiffMargin/ScrollDiffMarginFactory2012.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.Composition;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
Expand All @@ -21,10 +21,8 @@ public override IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost,
return null;

var marginCore = TryGetMarginCore(textViewHost);
if (marginCore == null)
return null;

return new ScrollDiffMargin(textViewHost.TextView, marginCore, containerMargin);
return marginCore == null ? null : new ScrollDiffMargin(textViewHost.TextView, marginCore, containerMargin);
}
}
}
6 changes: 2 additions & 4 deletions GitDiffMargin/ScrollDiffMarginFactory2013.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.Composition;
using System.ComponentModel.Composition;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
Expand All @@ -24,10 +24,8 @@ public override IWpfTextViewMargin CreateMargin(IWpfTextViewHost textViewHost,
return null;

var marginCore = TryGetMarginCore(textViewHost);
if (marginCore == null)
return null;

return new ScrollDiffMargin(textViewHost.TextView, marginCore, containerMargin);
return marginCore == null ? null : new ScrollDiffMargin(textViewHost.TextView, marginCore, containerMargin);
}
}
}

0 comments on commit 5980b7a

Please sign in to comment.