Browse Source

Fixed performance bug when pressing Backspace - we were unnecessarily building the visual line for the intermediate state where the previous character is selected but not deleted.

pull/39/merge
Daniel Grunwald 13 years ago
parent
commit
a7047035c4
  1. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs
  2. 2
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextAreaDefaultInputHandlers.cs

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/CaretNavigationCommandHandler.cs

@ -140,6 +140,7 @@ namespace ICSharpCode.AvalonEdit.Editing
TextViewPosition oldPosition = textArea.Caret.Position; TextViewPosition oldPosition = textArea.Caret.Position;
MoveCaret(textArea, direction); MoveCaret(textArea, direction);
textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldPosition, textArea.Caret.Position); textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldPosition, textArea.Caret.Position);
if (!textArea.Document.IsInUpdate) // if we're inside a larger update (e.g. called by EditingCommandHandler.OnDelete()), avoid calculating the caret rectangle now
textArea.Caret.BringCaretToView(); textArea.Caret.BringCaretToView();
} }
}; };

2
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/TextAreaDefaultInputHandlers.cs

@ -59,7 +59,7 @@ namespace ICSharpCode.AvalonEdit.Editing
// Work around WPF memory leak: // Work around WPF memory leak:
// KeyBinding retains a reference to whichever UIElement it is used in first. // KeyBinding retains a reference to whichever UIElement it is used in first.
// Using a dummy element for this purpose ensures that we don't leak // Using a dummy element for this purpose ensures that we don't leak
// a real text editor (which a potentially large document). // a real text editor (with a potentially large document).
UIElement dummyElement = new UIElement(); UIElement dummyElement = new UIElement();
dummyElement.InputBindings.AddRange(inputBindings); dummyElement.InputBindings.AddRange(inputBindings);
} }

Loading…
Cancel
Save