Skip to content

Commit

Permalink
If you use tabs, it will by default insert spaces
Browse files Browse the repository at this point in the history
There will be an Option to change it back. The logic behind this is tabs
should be for indentation, not alignments. Closes #9
  • Loading branch information
cpmcgrath committed Jul 13, 2012
1 parent 82da032 commit f79b6c7
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CodeAlignment.Common/AlignFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void AlignByDialog(bool alignFromCaret = false)

Alignment CreateAlignment(bool useRegex = false)
{
var alignment = new Alignment { View = Document };
var alignment = new Alignment { View = Document, UseIdeTabSettings = m_options.UseIdeTabSettings };

if (m_options.XmlTypes.Contains(Document.FileType))
alignment.Selector = new XmlScopeSelector();
Expand Down
9 changes: 5 additions & 4 deletions CodeAlignment.Common/Business/Alignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ namespace CMcG.CodeAlignment.Business
{
public class Alignment
{
public IDocument View { get; set; }
public IScopeSelector Selector { get; set; }
public IDelimiterFinder Finder { get; set; }
public IDocument View { get; set; }
public IScopeSelector Selector { get; set; }
public IDelimiterFinder Finder { get; set; }
public bool UseIdeTabSettings { get; set; }

public Alignment()
{
Expand Down Expand Up @@ -47,7 +48,7 @@ void CommitChanges(LineDetails[] data, int targetPosition)
string GetSpacesToInsert(int startIndex, int endIndex)
{
bool useSpaces = View.ConvertTabsToSpaces;
if (useSpaces)
if (useSpaces || !UseIdeTabSettings)
return string.Empty.PadLeft(endIndex - startIndex);

int spaces = endIndex % View.TabSize;
Expand Down
3 changes: 3 additions & 0 deletions CodeAlignment.Common/Business/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public Options()
XmlTypes = m_settings.XmlTypes.Cast<string>().ToArray();
ScopeSelectorLineValues = m_settings.ScopeSelectorLineValues;
ScopeSelectorLineEnds = m_settings.ScopeSelectorLineEnds;
UseIdeTabSettings = m_settings.UseIdeTabSettings;
}

public List<KeyShortcut> Shortcuts { get; set; }
Expand All @@ -45,6 +46,7 @@ string ToOrRegex(string input, string format)

public string ScopeSelectorLineValues { get; set; }
public string ScopeSelectorLineEnds { get; set; }
public bool UseIdeTabSettings { get; set; }

public string XmlTypesString
{
Expand Down Expand Up @@ -85,6 +87,7 @@ public void Save()
m_settings.XmlTypes.AddRange(XmlTypes);
m_settings.ScopeSelectorLineValues = ScopeSelectorLineValues;
m_settings.ScopeSelectorLineEnds = ScopeSelectorLineEnds;
m_settings.UseIdeTabSettings = UseIdeTabSettings;
m_settings.Save();
}
}
Expand Down
15 changes: 15 additions & 0 deletions CodeAlignment.Common/Options/ScreenGeneral.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions CodeAlignment.Common/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions CodeAlignment.Common/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,8 @@
<Setting Name="ScopeSelectorLineEnds" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="UseIdeTabSettings" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
3 changes: 3 additions & 0 deletions CodeAlignment.Common/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<setting name="ScopeSelectorLineEnds" serializeAs="String">
<value />
</setting>
<setting name="UseIdeTabSettings" serializeAs="String">
<value>False</value>
</setting>
</CMcG.CodeAlignment.Properties.Settings>
</userSettings>
</configuration>

0 comments on commit f79b6c7

Please sign in to comment.