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

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandy Armstrong <sandy@xamarin.com>2019-06-20 18:52:49 +0300
committerSandy Armstrong <sandy@xamarin.com>2019-06-20 20:55:58 +0300
commitea2bd325b8ed5b13aaa6de4df5da13e794e58546 (patch)
tree2770d4f6a5a0a37cf86e9791efbeee50cf10e386 /main/src/addins
parente0e3a2ac9b5e4f2ccaacc020481dcf2dddba42d6 (diff)
TextViewContent: Show column rulers, including new editorconfig value
Prefer new `rulers` value from editorconfig, which allows setting multiple vertical rulers (like in vscode). Then, check `max_line_length` like the old editor does. Finally, use the VSmac preference/policy system. Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/798040
Diffstat (limited to 'main/src/addins')
-rw-r--r--main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs b/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs
index 712baa7a8b..d9b7c6014b 100644
--- a/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs
+++ b/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs
@@ -387,6 +387,7 @@ namespace MonoDevelop.TextEditor
EditorOptions.ClearOptionValue (DefaultOptions.IndentSizeOptionName);
EditorOptions.ClearOptionValue (DefaultOptions.NewLineCharacterOptionName);
EditorOptions.ClearOptionValue (DefaultOptions.TrimTrailingWhiteSpaceOptionName);
+ EditorOptions.ClearOptionValue (DefaultTextViewOptions.VerticalRulersName);
return;
}
@@ -399,6 +400,10 @@ namespace MonoDevelop.TextEditor
EditorOptions.SetOptionValue (DefaultOptions.IndentSizeOptionName, currentPolicy.IndentWidth);
EditorOptions.SetOptionValue (DefaultOptions.NewLineCharacterOptionName, currentPolicy.GetEolMarker ());
EditorOptions.SetOptionValue (DefaultOptions.TrimTrailingWhiteSpaceOptionName, currentPolicy.RemoveTrailingWhitespace);
+
+ EditorOptions.SetOptionValue (
+ DefaultTextViewOptions.VerticalRulersName,
+ PropertyService.Get<bool> ("ShowRuler") ? new [] { currentPolicy.FileWidth } : Array.Empty<int> ());
}
private Task UpdateOptionsFromEditorConfigAsync (object sender, CodingConventionsChangedEventArgs args)
@@ -417,6 +422,29 @@ namespace MonoDevelop.TextEditor
if (editorConfigContext.CurrentConventions.UniversalConventions.TryGetAllowTrailingWhitespace (out var allowTrailingWhitespace))
EditorOptions.SetOptionValue (DefaultOptions.TrimTrailingWhiteSpaceOptionName, !allowTrailingWhitespace);
+ var setVerticalRulers = false;
+ int [] verticalRulers = null;
+
+ if (editorConfigContext.CurrentConventions.TryGetConventionValue<string> (EditorConfigService.RulersConvention, out var rulers)) {
+ setVerticalRulers = true;
+ if (!string.IsNullOrEmpty(rulers)) {
+ verticalRulers = Array.ConvertAll (rulers.Split (','), val => {
+ if (int.TryParse (val, out var col))
+ return col;
+ return 0;
+ });
+ }
+ } else if (editorConfigContext.CurrentConventions.TryGetConventionValue<string> (EditorConfigService.MaxLineLengthConvention, out var maxLineLength)) {
+ if (maxLineLength != "off" && int.TryParse (maxLineLength, out var i)) {
+ setVerticalRulers = true;
+ verticalRulers = new [] { i };
+ } else
+ setVerticalRulers = false;
+ }
+
+ if (setVerticalRulers)
+ EditorOptions.SetOptionValue (DefaultTextViewOptions.VerticalRulersName, verticalRulers ?? Array.Empty<int> ());
+
return Task.FromResult (true);
}