Skip to content

Commit 75fa700

Browse files
author
Denis Peshkov
authored
Merge pull request #8 from denis-peshkov/feature/7_Add_option_to_convert_Tab_Indentations_to_Spaces
Feature/7 add option to convert tab indentations to spaces
2 parents 6eee732 + 299410d commit 75fa700

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

art/context-menu.png

-25.1 KB
Loading

art/settings.png

-11.6 KB
Loading

src/TypeScriptDefinitionGenerator/Generator/IntellisenseWriter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public static string WriteTypeScript(IEnumerable<IntellisenseObject> objects)
7474
if (Options.EOLType == EOLType.LF)
7575
sb.Replace("\r\n", "\n");
7676

77+
if (!Options.IndentTab)
78+
sb.Replace("\t", new string(' ', Options.IndentTabSize));
79+
7780
return sb.ToString();
7881
}
7982

src/TypeScriptDefinitionGenerator/Options.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class OptionsDialogPage : DialogPage
3030
internal const bool _defDeclareModule = true;
3131
internal const bool _defIgnoreIntellisense = true;
3232
internal const EOLType _defEOLType = EOLType.LF;
33+
internal const bool _defIndentTab = true;
34+
internal const byte _defIndentTabSize = 2;
3335

3436
[Category("Casing")]
3537
[DisplayName("Camel case enum values")]
@@ -85,6 +87,18 @@ public class OptionsDialogPage : DialogPage
8587
[Description("Choose the EOL type Unix/Windows")]
8688
[DefaultValue(_defEOLType)]
8789
public EOLType EOLType { get; set; } = _defEOLType;
90+
91+
[Category("Settings")]
92+
[DisplayName("Indent Tab")]
93+
[Description("Choose indentation to use Tab/Space: default is Tab")]
94+
[DefaultValue(_defIndentTab)]
95+
public bool IndentTab { get; set; } = _defIndentTab;
96+
97+
[Category("Settings")]
98+
[DisplayName("Indent Tab Size")]
99+
[Description("Set amount Spaces to replace the Tab, when Indent Tab is off")]
100+
[DefaultValue(_defIndentTabSize)]
101+
public byte IndentTabSize { get; set; } = _defIndentTabSize;
88102
}
89103

90104
public class Options
@@ -111,6 +125,10 @@ public class Options
111125

112126
public static EOLType EOLType => overrides?.EOLType ?? DtsPackage.Options.EOLType;
113127

128+
public static bool IndentTab => overrides?.IndentTab ?? DtsPackage.Options.IndentTab;
129+
130+
public static byte IndentTabSize => overrides?.IndentTabSize ?? DtsPackage.Options.IndentTabSize;
131+
114132
public static bool WebEssentials2015 => overrides?.WebEssentials2015 ?? DtsPackage.Options.WebEssentials2015;
115133

116134
public static void ReadOptionOverrides(ProjectItem sourceItem, bool display = true)
@@ -200,6 +218,12 @@ internal class OptionsOverride
200218
// [JsonRequired]
201219
public EOLType EOLType { get; set; } = OptionsDialogPage._defEOLType;
202220

221+
// [JsonRequired]
222+
public bool IndentTab { get; set; } = OptionsDialogPage._defIndentTab;
223+
224+
// [JsonRequired]
225+
public byte IndentTabSize { get; set; } = OptionsDialogPage._defIndentTabSize;
226+
203227
// [JsonRequired]
204228
public bool WebEssentials2015 { get; set; } = OptionsDialogPage._defWebEssentials2015;
205229
}

0 commit comments

Comments
 (0)