From 50cd38a5d80aeb039f2aa976c02aab2bd1f7bef7 Mon Sep 17 00:00:00 2001 From: GaoCong <718497701@qq.com> Date: Wed, 13 Feb 2019 13:36:38 +0800 Subject: [PATCH 1/2] add multi-cursor support --- CaseConverter/ConvertCaseCommand.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/CaseConverter/ConvertCaseCommand.cs b/CaseConverter/ConvertCaseCommand.cs index dc07534..dfaf3ae 100644 --- a/CaseConverter/ConvertCaseCommand.cs +++ b/CaseConverter/ConvertCaseCommand.cs @@ -55,8 +55,30 @@ protected override void Execute(object sender, EventArgs e) var selection = textDocument.Selection; if (selection.IsEmpty == false) { - var selectedText = selection.Text; - selection.ReplaceText(selectedText, StringCaseConverter.Convert(selectedText, convertPatterns)); + //var selectedText = selection.Text; + //selection.ReplaceText(selectedText, StringCaseConverter.Convert(selectedText, convertPatterns)); + if (selection.TextRanges.Count > 1) + { + foreach (TextRange item in selection.TextRanges) + { + var text = item.StartPoint.GetText(item.EndPoint); + int options = (int)(vsFindOptions.vsFindOptionsMatchWholeWord | + vsFindOptions.vsFindOptionsMatchCase | + vsFindOptions.vsFindOptionsMatchInHiddenText | + vsFindOptions.vsFindOptionsSearchSubfolders | + vsFindOptions.vsFindOptionsKeepModifiedDocumentsOpen); + dte.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, + text, + options, + StringCaseConverter.Convert(text, convertPatterns), + vsFindTarget.vsFindTargetCurrentDocumentSelection, ResultsLocation: vsFindResultsLocation.vsFindResultsNone); + } + } + else + { + var selectedText = selection.Text; + selection.ReplaceText(selectedText, StringCaseConverter.Convert(selectedText, convertPatterns)); + } } else { From b3e3a657bfc6ae71dd781a0ce7dae6ad2709149c Mon Sep 17 00:00:00 2001 From: GaoCong <718497701@qq.com> Date: Wed, 13 Feb 2019 18:11:24 +0800 Subject: [PATCH 2/2] Solve the line break flashback bug --- CaseConverter/ConvertCaseCommand.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CaseConverter/ConvertCaseCommand.cs b/CaseConverter/ConvertCaseCommand.cs index dfaf3ae..c2e4852 100644 --- a/CaseConverter/ConvertCaseCommand.cs +++ b/CaseConverter/ConvertCaseCommand.cs @@ -62,6 +62,10 @@ protected override void Execute(object sender, EventArgs e) foreach (TextRange item in selection.TextRanges) { var text = item.StartPoint.GetText(item.EndPoint); + if (string.IsNullOrEmpty(text)) + { + continue; + } int options = (int)(vsFindOptions.vsFindOptionsMatchWholeWord | vsFindOptions.vsFindOptionsMatchCase | vsFindOptions.vsFindOptionsMatchInHiddenText |