Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 1d71b6c

Browse files
committed
Experimental fix for #24
1 parent c65ae45 commit 1d71b6c

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

UI/Components/EditorElement.xaml.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private async void TextArea_MouseDown(object sender, MouseButtonEventArgs e)
178178
e.Handled = true;
179179
var smDef = Program.Configs[Program.SelectedConfig].GetSMDef();
180180
var sm = (SMBaseDefinition) smDef.Functions.FirstOrDefault(i => i.Name == word);
181-
181+
182182
sm ??= smDef.Constants.FirstOrDefault(i =>
183183
i.Name.Equals(word, StringComparison.InvariantCultureIgnoreCase));
184184

@@ -190,13 +190,13 @@ private async void TextArea_MouseDown(object sender, MouseButtonEventArgs e)
190190
{
191191
var str = smEnum.Entries.FirstOrDefault(
192192
i => i.Equals(word, StringComparison.InvariantCultureIgnoreCase));
193-
193+
194194
if (str == null) continue;
195195
sm = smEnum;
196196
break;
197-
}
198-
199-
197+
}
198+
199+
200200
//TODO: Match EnumStruct and MethodMaps Fields and Methods
201201
sm ??= smDef.EnumStructs.FirstOrDefault(i =>
202202
i.Name.Equals(word, StringComparison.InvariantCultureIgnoreCase));
@@ -770,7 +770,6 @@ private void PrevMouseWheel(object sender, MouseWheelEventArgs e)
770770
private void editor_MouseDown(object sender, MouseButtonEventArgs e)
771771
{
772772
e.Handled = true;
773-
Console.WriteLine("PRESSED MOUSE DOWN");
774773
HideISAC();
775774
}
776775

UI/MainWindowCommands.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,14 @@ private void Command_TidyCode(bool All)
216216
foreach (var ee in editors)
217217
if (ee != null)
218218
{
219+
var currentCaret = ee.editor.TextArea.Caret.Offset;
220+
var currentLen = ee.editor.Text.Length;
219221
ee.editor.Document.BeginUpdate();
220222
var source = ee.editor.Text;
221223
ee.editor.Document.Replace(0, source.Length, SPSyntaxTidy.TidyUp(source));
222224
ee.editor.Document.EndUpdate();
225+
var diff = currentLen - ee.editor.Text.Length;
226+
ee.editor.TextArea.Caret.Offset = currentCaret + diff;
223227
}
224228
}
225229

0 commit comments

Comments
 (0)