Git Product home page Git Product logo

avalonedit's Introduction

AvalonEdit NuGet Build AvalonEdit

AvalonEdit is the name of the WPF-based text editor in SharpDevelop 4.x "Mirador" and beyond. It is also being used in ILSpy and many other projects.

Downloads

AvalonEdit is available as NuGet package. Usage details, documentation and more can be found on the AvalonEdit homepage

How to build

AvalonEdit is targeting net6.0-windows and net462 TFMs. Because of net6.0-windows you must have the .NET 6.0 SDK installed on your machine. Visual Studio 2022 Community and up is required for working with the solution (global.json will select the proper SDK to use for building for you).

Documentation

Check out the official documentation and the samples and articles wiki page

To build the Documentation you need to install Sandcastle from https://github.com/EWSoftware/SHFB/releases (currently validated tooling is v2021.4.9.0)

The build of the Documentation can take very long, please be patient.

License

AvalonEdit is distributed under the MIT License.

Projects using AvalonEdit

A good place to start are the "top 10" listed under GitHub Usage for the AvalonEdit package on NuGet.

Note: if your project is not listed here, let us know! :)

avalonedit's People

Contributors

akspotw avatar anakic avatar christophwille avatar dependabot[bot] avatar dgrunwald avatar doug24 avatar dsrbecky avatar eusebiu avatar heldersepu avatar jimfoye avatar jogibear9988 avatar kekekeks avatar lellid avatar ltrzesniewski avatar menees avatar mkonicek avatar mrward avatar nickelony avatar nippur72 avatar rachamimyaakobov avatar richardbuckle avatar rpinski avatar siegfriedpammer avatar sloutsky avatar sokar92 avatar ssarangi avatar timgblack avatar tobijdc avatar yyjdelete avatar zuijin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avalonedit's Issues

SelectedItem in completion window

Hi ,

I am trying to do an enum on the selected option from the completion window. selecteditem does not do it for me for some reason.

I would appreciate some help with this please

Thanks

FoldingManager.AllFoldings is empty despite I see foldings in control in a TabStrip.

Hi I built an IronPython embedded tool and I am using your control to display the python snippets.

i recently through the use of the Python Abstract Parse tree and your Foldings engine built a PythonFoldingStratgy.

It works pretty good until I switch focus among tabs each window loses the collapsed/expanded state of its foldings.

Since I already derived from TextEditor to provide a string property for setting the source and to load the Python Syntax Highlighting Rules...I figured I could just cache the collapsed state of the foldings and restore them when I got focus.

But when I look at the AllFolding property of the foldingManager I found that it had no items so i could not cache them.

Is there some other property I should be looking at?

Copying empty selection clears clipboard

When user tries to copy text from TextEditor while the selection is empty, the clipboard is cleared. This is not expected, since most text editors don't behave this way.

Clipboard should not be cleared, when user attempts to do this.

Bug with multicarret (rectangle selection) delete

If you try to delete symbols with multicarret (rectangle selection) while having 0 visual columns (by pressing backspace or del), you will have your selection flushed back to single line carret and only 1 symbol will be deleted.
Back in 4.3.1 everything was fine with it

Make folding elements colors customizable

When using a dark theme, the folding elements (markers and lines) does not show correctly as they have fixed colors (e.g. Brush.White).

I think it should be given possibility to customize them, my suggestion is to add the following to the FoldingManager object:

  • FoldingMarkerBrush
  • FoldingMarkerBackgroundBrush
  • SelectedFoldingMarkerBrush
  • SelectedFoldingMarkerBackgroundBrush

Would that be acceptable? In case I would write a pull request.

Poor performances when typing in rectangle selection

On a file with about 1000 lines of text and syntax highlighting turned on, making a rectangle selection with more ~15 lines makes editing inside the selection very slow, dropping to something like 1 character per second.

Alt-Keypress not marked as handled when rectangular selection is done

In my application, I use AvalonEdit as text editor, whilst also having a third-party Ribbon control. That Ribbon control shows keyboard shortcuts when the user presses the Alt-Key. In general this works.

However, when doing a rectangular selection using the mouse (i.e. press Alt, drag with mouse, release Alt), the Alt-KeyUp event is not marked as handled by AvalonEdit. This results in the Ribbon incorrectly showing the keyboard shortcuts (since it seems that user simply pressed and released the Alt-Key).

Completion description tooltip does not move with completion window

Open a code completion popup and select an item that has an XmlDoc description.

Then, scroll in the text editor; or move the SharpDevelop window.

Expected result: the completion popup and description tooltip move with the text.
Actual result: only the completion popup moves with the text, the description tooltip stays in place.

AvalonEdit binding works BUT not in an ItemsControl ???

I can make AvalonEdit show text bound to a ViewModel`s simple string property.

I can make a TextBox show text bound to a ObservableCollection

I can NOT make AvalonEdit show text bound to a ObservableCollection

I get in no case any binding errors from here all is fine.

I use Visual Studio 2013

with a .NET 3.5 project.

I have referenced the System.Windows.Interactivity.dll because I use a custom Behavior to make the AvalonEdit.Text property fit more in the MVVM pattern.

I have attached a sample project where you can reproduce the behavior.

http://www.file-upload.net/download-9067428/ExpanderTest.7z.html

Make Y offset to be a multiple of line height

There is a possible incorrect behavior I've found I would like to discuss:

When you navigate with page down, the caret is forced into view by TextView.MakeVisible(), but that often makes the scroll Y offset to be unaligned respect to text lines, causing a partially covered top line (very noticeable with big fonts).

IMO, the correct behavior should be forcing newScrollOffset.Y to be a perfect multiple of DefaultLineHeight, so that the first line is always "in sync". This is what all other editors mostly do (e.g. VS).

I was thinking something like this:

newScrollOffset.Y = Math.Floor(newScrollOffset.Y / DefaultLineHeight) * DefaultLineHeight;

But I don't know if that fix is correct to, because of this DefaultLineHeight comment:

/// Gets the default line height. This is the height of an empty line or a line containing regular text.
/// Lines that include formatted text or custom UI elements may have a different line height.

What do you think?

DefaultIndentationStrategy fails with spaces right of the caret

I think there is a small (and annoying) defect, I don't think it's a feature:

When you press Enter to go to the new line, the automatic indentation fails if there are spaces right of the caret at the moment of pressing Enter.

Example:

   sometext     I      ยถ

pressing enter at the "I" (symbolizing the caret) does not move under the "s" of "sometext", but goes instead to the start of line.

But if it's

   sometextIยถ

then it moves correctly.

I hope I have explained it well.

All this with DefaultIndentationStrategy and TextEditor.Options.IndentationSize = 3;

AvalonEdit crash while performing a block edit including a folded section

See http://community.sharpdevelop.net/forums/t/22196.aspx

  1. Press Alt for block selection
  2. Select text containing a folded section
  3. Press backspace

==> Crash:

SharpDevelop Version : 5.1.0.5096-Beta 2-27c8cac0
.NET Version         : 4.5.51209
OS Version           : Microsoft Windows NT 6.1.7601 Service Pack 1
Current culture      : German (Germany) (de-DE)
Current UI language  : en
Running under WOW6432, processor architecture: x86-64
Working Set Memory   : 132560kb
GC Heap Memory       : 18178kb
Unhandled WPF exception
Exception thrown:
System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.AvalonEdit.Rendering.HeightTree.GetNodeByIndex(Int32 index)
   at ICSharpCode.AvalonEdit.Rendering.TextView.GetVisualTopByDocumentLine(Int32 line)
   at ICSharpCode.AvalonEdit.Editing.RectangleSelection.ReplaceSelectionWithText(String newText)
   at ICSharpCode.AvalonEdit.Editing.TextArea.RemoveSelectedText()
   at ICSharpCode.AvalonEdit.Editing.EditingCommandHandler.<>c__DisplayClass12_0.<OnDelete>b__0(Object target, ExecutedRoutedEventArgs args)
   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
   at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
   at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
---- Recent log messages:
13:52:33.473 [1] INFO - Open file C:\Users\bramerd\Documents\SharpDevelop Projects\Crash\Crash\Program.cs
13:52:33.473 [1] DEBUG - Service startup: ICSharpCode.SharpDevelop.Workbench.IDisplayBindingService
13:52:33.538 [1] INFO - Loading addin Search & Replace
13:52:33.553 [1] DEBUG - Service startup: ICSharpCode.SharpDevelop.ILanguageService
13:52:33.644 [1] DEBUG - Update Foldings
13:52:33.648 [1] DEBUG - Service startup: ICSharpCode.SharpDevelop.Editor.Bookmarks.IBookmarkManager
13:52:33.661 [1] DEBUG - Trying to restore memento of '[AvalonEditViewContent C:\Users\bramerd\Documents\SharpDevelop Projects\Crash\Crash\Program.cs]' from key '1e13ec5:C:\USERS\BRAMERD\DOCUMENTS\SHARPDEVELOP PROJECTS\CRASH\CRASH\PROGRAM.CS'
13:52:33.757 [1] DEBUG - NavigationService -- resume logging
13:52:33.777 [1] DEBUG - ActiveContentChanged to [AvalonEditViewContent C:\Users\bramerd\Documents\SharpDevelop Projects\Crash\Crash\Program.cs]
13:52:33.777 [1] DEBUG - ActiveWorkbenchWindowChanged to [AvalonWorkbenchWindow: Program.cs]
13:52:33.777 [1] INFO - CurrentProject changed to Crash
13:52:33.778 [1] DEBUG - NavigationService
    ActiveViewContent: Program.cs
             Subview: ${res:FormsDesigner.DesignTabPages.SourceTabPage}
13:52:33.778 [1] DEBUG - ActiveViewContentChanged to [AvalonEditViewContent C:\Users\bramerd\Documents\SharpDevelop Projects\Crash\Crash\Program.cs]
13:52:33.815 [18] DEBUG - Git: OverlayIconManager Thread finished
13:52:33.845 [1] INFO - Loading addin ASP.NET MVC Binding
13:52:33.849 [1] DEBUG - Service startup: ICSharpCode.UnitTesting.ITestService
13:52:33.895 [LoadSolutionProjects] DEBUG - Crash: ParseFiles() finished. 0 files were re-used from CC cache; 2 files were parsed (2 of those are serializable)
13:52:33.944 [1] DEBUG - Update Foldings
13:52:34.123 [LoadSolutionProjects] DEBUG - LoadSolutionProjectsThread finished after 00:00:00.7448732
13:52:34.702 [5] DEBUG - Resolved (Line 16, Col 17) to 
13:54:00.198 [1] DEBUG - Resolved (Line 27, Col 4) to 
13:54:01.930 [19] DEBUG - Resolved (Line 15, Col 14) to 
13:54:02.886 [1] DEBUG - Resolved (Line 19, Col 14) to 
14:06:47.331 [1] DEBUG - Resolved (Line 16, Col 27) to 
14:06:47.667 [1] ERROR - Unhandled WPF exception
--> Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at ICSharpCode.AvalonEdit.Rendering.HeightTree.GetNodeByIndex(Int32 index)
   at ICSharpCode.AvalonEdit.Rendering.TextView.GetVisualTopByDocumentLine(Int32 line)
   at ICSharpCode.AvalonEdit.Editing.RectangleSelection.ReplaceSelectionWithText(String newText)
   at ICSharpCode.AvalonEdit.Editing.TextArea.RemoveSelectedText()
   at ICSharpCode.AvalonEdit.Editing.EditingCommandHandler.<>c__DisplayClass12_0.<OnDelete>b__0(Object target, ExecutedRoutedEventArgs args)
   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
   at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs)
   at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e)
   at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
   at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
---- Post-error application state information:
Installed 3rd party AddIns: 
ProjectService.CurrentSolution: [Solution C:\Users\bramerd\Documents\SharpDevelop Projects\Crash\Crash.sln with 1 projects]
ProjectService.CurrentProject: [CSharpProject: Crash]
Workbench.ActiveContent: [AvalonEditViewContent C:\Users\bramerd\Documents\SharpDevelop Projects\Crash\Crash\Program.cs]

Expose "MinimumDistanceToViewBorder"

This is request from the message board on the CodeProject article:

Hey,

could you please make the "MinimumDistanceToViewBorder" in Caret.cs to a property or so.
Reason:

  • If I move the caret with the mouse the SelectionMouseHandler calls BringCaretToView(5.0). This is OK.
  • If I just go into the last visible line and enter a text BringCaretToView(MinimumDistanceToViewBorder) is called. In my opinion MinimumDistanceToViewBorder = 30 is far to large. The whole text just jumps to the top and the user looses the context. I could not find a way ro reduce MinimumDistanceToViewBorder to 5.0. Even with reflection there was no success, because it is a constant.

Faulty ArgumentOutOfRangeException message in TextEditor.Select(int start, int length)

I was getting funky exception messages like
System.ArgumentOutOfRangeException: Value must be between 0 and 789, Parameter name: length, Actual value was 41.

Huh? O.o

I debugged the source and realized that the value really was out of range, it was just the message which was wrong!

The line

throw new ArgumentOutOfRangeException("length", length, "Value must be between 0 and " + (documentLength - length));

should be

throw new ArgumentOutOfRangeException("length", length, "Value must be between 0 and " + (documentLength - start));

Thanks!

Allow matching on partial words combined with camel case for autocompletion (Resharper style)

I'm a user of https://github.com/lukebuehler/CShell which uses AvalonEdit for code completion. I originally filed this at lukebuehler/CShell#25 but am refiling it here.

I'd like it if code completion allowed on matching within a word combined with the camel case completion. For example if I want DateTime I could enter dt, see that there are still a lot of types that match dt via camel case completion and continue on to type dtime, which will filter the list down to just a couple choices, one of which is DateTime.

This idea is heavily based on my use of Resharper which allows this sort of query.

One approach to this would be:

  1. The first letter of the query must match the first letter of any word in the text.
  2. Each subsequent letter of the query must match either the next letter in the text or the first letter of the next word in the text.

This could alternately require the query to match starting at the beginning of the text by changing 1. to:

  1. The first letter of the query must match the first letter in the text.

Rendering selection Top is off by 1 pixel

The selection box is not correctly aligned in y position with the line and caret, as shown by the following image:

avalon

See how the caret (between var and buffer) looks shifted up by 1 pixel respect to selection box. The bug is more evident on certain font sizes.

The above image was produced by having Options.SelectionBorder.Thickness = 0 and using a Consolas font family and having caret thickness of 2 (in control panel).

I fixed it by subtracting 0.5 in BackgroundGeometryBuilder.cs, but don't know if it's correct:

double y = visualLine.GetTextLineVisualYPosition(line, VisualYPosition.LineTop)-0.5;

Behavior of 'end' key is incorrect if 'show spaces' is not enabled

With show spaces on, the 'end' key jumps to the end of the line, after any whitespace.
With show spaces off, it jumps to the end of the line, but before any trailing whitespace.

The behavior should be consistent between the two settings. Also, I think the first behavior is more useful -- trailing whitespace usually is unintentional, and one should be able to find it by pressing 'end'. Notepad++ also jumps to the end of line after trailing whitespace.

Search operation executes on dispatcher thread

Hi, this project is just brilliant and I've been using it for a couple years for now.
The only one problem is UI freezes when working with huge documents >10Mb and active search running.
The root of the problem is that offsets calculation process is running in the main UI thread, matching big text using regexps takes a lot of time ( e.x. on my machine when 20 Mb file is opened and any type of search active any keypress leads to 2,2 secs delay, matching text with simple regex takes about 2,1 secs).
So the first thought - move matching phase to another thread, additionally add interception code in each iteration so that any running background process could be easily stopped by new one (typing -> search started, typing before search completed -> search process stopped and new one started).

I've worked a bit on this problem and have some implementation in my fork (worked out dispatcher issues + interception implementation), no more freezes during typing + simplified search dependencies, unfortunately I've abandoned some search functionality? but I'm sure that with your help we can implement match whole word without document dependency (so it could run in parallel thread).

If you are interested in this type of functionality I can upload performance reports and send pull request.

Again, thanks for your work.

Disabled line appears when set TextFormattingMode.Display

  1. Create new wpf application project .net framework 4.0.
  2. Add TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display); after InitializeComponent();
  3. Try to drag text.
  4. Disabled line appears at the intersection of the lines.

Text not displayed in code completion window when AvalonEdit used from F# code

Everything seems to work fine, as if the code completion text was there, it is just not displayed.
The same behaviour observed on a version of AvalonEdit from 2013 and on the last one.
untitled

The minimalistic F# code for using AvalonEdit follows. (Program.fs, Gui.fs, CompletionData.fs, Gui.xaml).
These References are sufficient for running the code:
untitled1

Program.fs:

//Imported modules/namespaces:
    // System:
open System
    // Project:
open Gui

[<EntryPoint>]
[<STAThread>]
let main _ =
    Osdeui().Run()

Gui.fs:

module Gui

open FSharp.Data
open System
open System.Net
open System.Runtime
open System.Windows
open System.Windows.Controls
open ICSharpCode.AvalonEdit
open ICSharpCode.AvalonEdit.CodeCompletion
open System.Windows.Input

open CompletionData

let appname = "codeCompletionTest"

// Load GUI from URI
//   appname .. name of application
//   xamlName .. name of XAML file
let createWindow appname xamlName =
    let uriString = sprintf "/%s;component/%s" appname xamlName
    let uri = System.Uri(uriString, System.UriKind.Relative)
    Application.LoadComponent(uri) :?> Window

let (?) (window : Window) name =
    window.FindName name
    |> unbox

let inline (+=) (event : IEvent<_, _>) handler =
    (event :> Microsoft.FSharp.Control.IDelegateEvent<_>).AddHandler(RoutedEventHandler(handler))

type Osdeui (xaml : Window) as this = class

    let exit : Button = xaml?exit
    let textEditor : TextEditor = xaml?txtEditor

    // code completion
    let completionWindow = new CompletionWindow(textEditor.TextArea)


    do
        exit.Click += this.exitClick
        textEditor.TextArea.TextEntering.AddHandler(TextCompositionEventHandler this.textEditor_TextArea_TextEntering)
        textEditor.TextArea.TextEntered.AddHandler(TextCompositionEventHandler this.textEditor_TextArea_TextEntered)


    new () = Osdeui (createWindow appname "Gui.xaml")

    member this.exitClick (_ : obj) (_ : RoutedEventArgs) =
        Application.Current.Shutdown()

    member this.textEditor_TextArea_TextEntering (sender : obj) (e : TextCompositionEventArgs) =
        if (e.Text.Length > 0 && completionWindow <> null) then
            (
                if (not (Char.IsLetterOrDigit (e.Text.[0]))) then (
                    // Whenever a non-letter is typed while the completion window is open,
                    // insert the currently selected element.
                    completionWindow.CompletionList.RequestInsertion(e)
                ) else ()
            ) else ()        

    member this.textEditor_TextArea_TextEntered (sender : obj) (e : TextCompositionEventArgs) =
         (
            if (e.Text = " ") then (
                // Open code completion after the user has pressed space:
                let completionWindow = new CompletionWindow(textEditor.TextArea)
                let data = completionWindow.CompletionList.CompletionData;
                let items = ["Item1"; "Item2"; "Item3"]
                List.iter (fun x -> data.Add(new MyCompletionData(x))) items

                completionWindow.Show();

                completionWindow.Closed.AddHandler(EventHandler (fun _ _ -> (completionWindow.Close())))
            ) else ()
        )

    member this.Run () =
        (new Application()).Run xaml

end

CompletionData.fs:

module CompletionData

open ICSharpCode.AvalonEdit.CodeCompletion
open System
open System.Windows.Media.Imaging

/// Implements AvalonEdit ICompletionData interface to provide the entries in the
/// completion drop down.
type MyCompletionData (text:string) = 
    let _text = text

    interface ICompletionData with

        member this.Complete (textArea, completionSegment, insertionRequestEventArgs) =
            textArea.Document.Replace(completionSegment, ((this :> ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData).Text: string));

        // Use this property if you want to show a fancy UIElement in the list.
        member this.Content
            with get () = (this :> ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData).Text :> obj

         member this.Description
            with get () = ("Description for " + (this :> ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData).Text ) :> obj

        member  this.Image
            with get () = null

        member this.Priority
            with get () = 1.0

        member this.Text = _text

Gui.xaml:

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:avalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
  xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
  Width="1018.944" Height="360" Title="OSLC">
    <StackPanel HorizontalAlignment="Left" Height="329" VerticalAlignment="Top" Width="1009">
        <StackPanel Height="28" Orientation="Horizontal">
            <Button x:Name="exit" Content="exit" Width="75" HorizontalAlignment="Right" HorizontalContentAlignment="Center"/>
        </StackPanel>
        <StackPanel Height="277">
            <avalonEdit:TextEditor x:Name="txtEditor" Height="262" FontFamily="Consolas" FontSize="10pt"/>
        </StackPanel>

    </StackPanel>
</Window>

Double click on word should move caret to end of selection

If you double click on a word to select it, selection is correct but caret isn't moved at the end of word/selection as in normal text editors.

I tried to fix it myself in SelectionMouseHandler.cs\textArea_MouseLeftButtonDown() with

textArea.Caret.Offset = startWord.EndOffset;                     

but the caret keeps returning on the old position. Perhaps it's related to this comment:

// Set caret offset, but limit the caret to stay inside the selection.
// in whole-word selection, it's otherwise possible that we get the caret outside the
// selection - but the TextArea doesn't like that and will reset the selection, causing
// flickering.

but I don't know how to handle it.

Provide better ability to theme the editor (light/dark)

AvalonEdit is a great editor but is not keeping up with the times. AvalonEdit should provide better theme support for Light and Dark themes. If this is something that is not deemed necessary, could someone at least explain how I could go about skinning the editor in a dark theme (see VS 2013 Dark theme as an example).

Copy of rectangle selection should include virtual spaces

If virtual space is enabled, the copy operation of a rectangle selection should include the virtual spaces at the end of each line. This way when you later paste the content of the clipboard, the rectangle-shaped content is preserved.

Example:

Original, with rectangle selection moving letters before numbers:
123 a
123 ab
123 abc

Copy and paste with current behaviour:
a123 
ab123 
abc123 

Should do instead:
a   123 
ab  123 
abc 123 

ConvertTabsToSpaces does not affect paste

Tabs can still be pasted into a document when the ConvertTabsToSpaces option is set to true. This feels inconsistent, and I believe most editors will convert pasted tabs when their corresponding setting is enabled (Visual Studio does at least).

OnPaste does not use Modified Text

Example code:

    DataObject.AddPastingHandler(AvalonEditBox, OnPaste);

    private void OnPaste(object sender, DataObjectPastingEventArgs e)
    {
        var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true);
        if (!isText) return;
        var text = (string)e.SourceDataObject.GetData(DataFormats.UnicodeText);

        var dataObject = new DataObject();
        dataObject.SetData(DataFormats.UnicodeText, text.ReplaceSpecialChars());
        e.DataObject = dataObject;
    }

The OnPaste method in ICSharpCode.AvalonEdit.Editing.EditingCommandHandler.cs aquires the modified format (line 457) but not the modified text from the raised event.

[SyntaxHighlighter Bug] background color doesn't reset with nested rules

I have a simple xshd for syntax highlighting liquid templates.

<?xml version="1.0"?>

<!-- See https://github.com/icsharpcode/SharpDevelop/wiki/Syntax-highlighting -->

<SyntaxDefinition name = "dotliquid" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008" 
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    >

    <RuleSet >
        <Span background="Black" foreground="LightGreen" >
            <Begin >{%</Begin>
            <End>%}</End>
            <RuleSet >
                <Span background="Black" foreground="LightBlue" >
                    <Begin >{{</Begin>
                    <End >}}</End>
                </Span>
            </RuleSet>
        </Span>
        <Span background="Black" foreground="LightBlue" >
            <Begin >{{</Begin>
            <End >}}</End>
        </Span>


    </RuleSet>

</SyntaxDefinition>

But the result is

image

So {{}} type tags can be embedded in {%%} type tags but the background color is reset to white after the closing }}

Rectangle selection does not handle backspace key

When in rectangle selection, you can type text and have it inserted on each row of the selection; but if you use backspace to edit, the selection cancels and the backspace is applied only the line where the caret is.

Ideally, backspace should be applied on each line of the selection (like in Visual Studio).

Automatic indentation wrongly respositions AnchorSegment/TextSegment

With auto-indentation active, AnchorSegment and TextSegment start offsets are moved to the end of the line that contains them when an inserted line break causes new indentation.

The explanation seems to be that auto-indentation works by removing the whole of the new line before reinserting it with a tab at the beginning. However, automatic updating of AnchorSegment offsets is implemented such that removals spanning the start offset cause the start offset to be moved to the end of the line.

Steps to reproduce:

Step 1. Programatically create an AnchorSegment spanning some portion of a line, e.g. at the end of the Window1 constructor in Window1.xaml.cs in the sample:

textEditor.Text = "Blah blah blah *this is an anchor segment* blah blah";
AnchorSegment a = new AnchorSegment(textEditor.TextArea.Document, 15, 25);

This creates the following text:

Blah blah blah *this is an anchor segment* blah blah

where * indicates the start and end offsets of the AnchorSegment.

Step 2. Run the sample, with C# selected in the dropdown, and use the UI to insert a carriage return before the start of the AnchorSegment.

Actual behaviour: AnchorSegment moves to the end of the line.

Blah bl
          ah blah this is an anchor segment blah blah**

Expected behaviour:

Blah bl
          ah blah *this is an anchor segment* blah blah

ScrollToEnd() is inefficient

AvalonEdit ScrollToEnd() is inefficient -- it sets ScrollOffset to infinity, and relies on the bounds check in arrange() to restore a sane ScrollOffset.
Unfortunately, this has the effect of destroying all cached visual lines. This makes ScrollToEnd() inefficient in log-viewer style applications that frequently append to the document and call ScrollToEnd().

Baml2006.TypeConverterMarkupExtension on creating instance of ICSharpCode.AvalonEdit.TextEditor.

Hi,

i have a program released with few hundred users. One of them is observing a strange exception.
The program is crashing with a strange Baml2006.TypeConverterMarkupExtension exception.
We've managed to track the exception down to the loading of the avalonedit (Exception log: at the end of the issue).

As a test, i've send him a simple wpf-prog. which does nothing else than loading a plain TextEditor
(nothing else, no highlighting folding or anything else).
It crashes with the same error (with a simple TextBox it works) so we can be sure the avlonedit is the "maker" of the exception.
(BTW: newest avalonedit version added via NuGet)

The strangest part is the inner exception. It seems, that something tries to "save?!" a temporary cursor file and load it afterwards but the file does not seem to exists.

I cannot reproduce it (as well as all other users). But I'am in close contact to the person which observes the error so I can send him everything you suggesting here.

I have also a (big) exception log for you:

Section: SPEDIT MAIN
.NET Version: 4.0.30319.34209
OS: Microsoft Windows NT 6.1.7601 Service Pack 1
64 bit OS: TRUE
64 bit mode: TRUE
Dir: C:\Users\*****\Desktop\errorversions_spedit_2
Working Set: 74864 kb
Installed UI Culture: en-US
Current UI Culture: en-US
Current Culture: en-US

Exception
Message:
Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.
Stacktrace:
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.ResourceDictionary.CreateObject(KeyRecord key)
   at System.Windows.ResourceDictionary.OnGettingValue(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.OnGettingValuePrivate(Object key, Object& value, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValueWithoutLock(Object key, Boolean& canCache)
   at System.Windows.ResourceDictionary.GetValue(Object key, Boolean& canCache)
   at System.Windows.SystemResources.LookupResourceInDictionary(ResourceDictionary dictionary, Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
   at System.Windows.SystemResources.FindDictionaryResource(Object key, Type typeKey, ResourceKey resourceKey, Boolean isTraceEnabled, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference, Boolean& canCache)
   at System.Windows.SystemResources.FindResourceInternal(Object key, Boolean allowDeferredResourceReference, Boolean mustReturnDeferredResourceReference)
   at System.Windows.StyleHelper.GetThemeStyle(FrameworkElement fe, FrameworkContentElement fce)
   at System.Windows.FrameworkElement.UpdateThemeStyleProperty()
   at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
   at System.Windows.FrameworkElement.OnVisualParentChanged(DependencyObject oldParent)
   at System.Windows.Media.Visual.FireOnVisualParentChanged(DependencyObject oldParent)
   at System.Windows.Media.VisualCollection.Add(Visual visual)
   at System.Windows.Controls.Panel.GenerateChildren()
   at System.Windows.Controls.Panel.get_InternalChildren()
   at System.Windows.Controls.StackPanel.StackMeasureHelper(IStackMeasure measureElement, IStackMeasureScrollData scrollData, Size constraint)
   at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ItemsPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ScrollContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.ScrollViewer.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.Interop.HwndSource.SetLayoutSize()
   at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
   at System.Windows.Window.SetRootVisualAndUpdateSTC()
   at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at System.Windows.Application.<RunInternal>b__f(Object obj)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunInternal(Window window)
   at Spedit.Program.Main(String[] args)
Source: PresentationFramework
HResult Code: -2146233087
Helplink: null
Targetsite Name: Load
Inner exception:
{
Message:
The file exists.

Stacktrace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Path.InternalGetTempFileName(Boolean checkHost)
   at System.Windows.Input.Cursor.LoadFromStream(Stream cursorStream)
   at System.Windows.Input.CursorConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
Source: mscorlib
HResult Code: -2147024816
Helplink: null
Targetsite Name: WinIOError
Inner Exception: null
}

I hope we can track the error down together.

Control disables when applying Telerik theme to ScrollViewer

First of all, this is a very cool control. Great job! This is an obscure situation, but I notice that the control becomes disabled when I apply the following global style to ScrollViewers. My project is using Telerik and I'm trying to apply the theme to the project's ScrollViewers. Once I remove this the control works as expected

    <Style TargetType="ScrollViewer">
        <Setter Property="telerik:StyleManager.Theme" Value="{StaticResource Theme}"/>
        <Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Disabled"/>
    </Style>

Pasting non-unicode text causes exception

Scenario: I am working on a linux machine, with an iceweasel instance running on one monitor; and rdesktop running on the other. The rdesktop instance is logged in to a Windows instance running SharpDevelop/AvalonEdit.

When copying text in iceweasel and trying to paste it in AvalonEdit, the following exception occurs:

System.ArgumentException: 'UnicodeText' data format is not present on DataObject.
   at System.Windows.DataObjectPastingEventArgs..ctor(IDataObject dataObject, Boolean isDragDrop, String formatToApply)
   at ICSharpCode.AvalonEdit.Editing.EditingCommandHandler.OnPaste(Object target, ExecutedRoutedEventArgs args)
   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

As a workaround, I first paste the text into a notepad instance on the Windows machine, and copy it from there to paste into AvalonEdit.

Performance issue with 'show spaces' and long lines

SD-1916, originally created on 10/16/2012 18:10:03 by Daniel Grunwald

  1. Enable the "Show spaces" and "Show tabs" options

  2. Create a new text file inside SharpDevelop

  3. Copy this gist: https://gist.github.com/3899997 into the editor

  4. Use operations like Ctrl+A or rectangular selection

    Both step 3 and the operations in step 4 feel quite slow. With "Show
    tabs" and "Show spaces" disabled, it feels significantly faster.

    This seems to be related to EnableEmailHyperlinks/EnableHyperlinks;
    turning these two features off increases performance noticably (though
    it's still slower than without "Show spaces").


Comment from Daniel Grunwald on 10/16/2012 18:14:46:
AvalonEdit.Benchmark results from my notebook, "ModifyLongLine" with
longLineLength=500, default window dimensions.
With show spaces: 4 FPS
With show spaces but without EnableEmailHyperlinks/EnableHyperlinks: 11
FPS
Without show spaces: 20 FPS
Disabling EnableEmailHyperlinks/EnableHyperlinks has no effect without
show spaces.

Smarter Word Wrap for Markdown Syntax

Word wrap works fine but could be enhanced to account for front matter in lists: Example:

- now is the time
for all good ...

Prefer

- now is the time
  for all good ...

Perhaps an additional API? Something like InheritWordWrapWithFrontMatter? The API could take a list of front matter items maybe.

Allow code completion matching on the first letter of each word in camel case text

I'm using CShell, which makes use of the AvalonEdit project for code completion. This was originally filed at lukebuehler/CShell#26 but since he's using your control it would need to be fixed here. I've cleaned up the description a bit to hopefully make it clearer what I'm requesting.

Below when I refer to "pascal case" or "camel case" I'm referring to the styles given, e.g., here: http://msdn.microsoft.com/en-us/library/x2dbyw72(v=vs.71).aspx.

For the purpose of code completion I would like the query tist to match the text thisIsSomeText because it matches the first letter of each word in the text.

This comes up most often when trying to use auto completion to complete a variable, which I typically name using camel case.

This request seems reasonable because tist does in fact match the text ThisIsSomeText (note pascal case instead of camel case this time).

You may also want to consider fixing what is probably a bug in the current implementation: ist matches thisIsSomeText because it matches all the upper case letters even though it doesn't match the first letter of the first word.

Adding a highlighting rule after app start doesn't apply the highlighting rule

I have a base set of highlighting rules I load at start, but continuously scan the document for new ones and add them on the fly and the text that matches, if displayed on the screen doesn't get the new highlight. If I re-size the window to not display the text that should match the new rule and then move it back so the text is displayed it is now highlighted,

Also for the same line of text (if its not highlighted) simply selecting ANY text on that line will apply the rule and the text is proper highlighted.

AST Based Highlighter

Is it possible to implement a highlighter based on something other than Regex (an AST for instance)? The current IHighlightDefinition appears to only work wth Regex.

OnDrop does not use Modified Text

This is similar to a bug #18.

The text for pasting is acquired before the OnPaste event is raised. This does not allow event handlers to modify the pasted text. See SelectionMouseHandler.cs line 225. The text needs to be reacquired after the paste event is raised in case the event handler has modified the data object.

Performance issue with word wrap

I use AvalonEdit to display XML data, and sometimes that data include really long lines without spaces (at most it's 25MB byte[] data encoded as base64).
When I enable WordWrap performance drops really bad.

And even with WordWrap disabled lines are still wrapping after 9600 symbols, so performance drops to unacceptable levels in worst case. Workaround is checking string and splitting lines by 8000 symbols - then performance is OK

Unhandled WPF Exception at ICSharpCode.AvalonEdit.Utils.CharRope

See http://community.sharpdevelop.net/forums/t/22188.aspx for full exception output.

SharpDevelop Version : 5.1.0.5084-Beta 2-c5791b46
.NET Version         : 4.5.50938
OS Version           : Microsoft Windows NT 6.1.7601 Service Pack 1
Current culture      : English (United States) (en-US)
Running under WOW6432, processor architecture: x86-64
Working Set Memory   : 512768kb
GC Heap Memory       : 209302kb

Unhandled WPF exception
Exception thrown:
System.OverflowException: Arithmetic operation resulted in an overflow.
   at ICSharpCode.AvalonEdit.Utils.CharRope.ToString(Rope`1 rope, Int32 startIndex, Int32 length)
   at ICSharpCode.AvalonEdit.Document.TextDocument.GetText(Int32 offset, Int32 length)
   at CSharpBinding.Parser.TParser.AddCommentTags(SyntaxTree cu, IList`1 tagComments, ITextSource fileContent, FileName fileName, IDocument& document)
   at CSharpBinding.Parser.TParser.Parse(FileName fileName, ITextSource fileContent, Boolean fullParseInformationRequested, IProject parentProject, CancellationToken cancellationToken)
   at ICSharpCode.SharpDevelop.Parser.ParserServiceEntry.ParseWithExceptionHandling(ITextSource fileContent, Boolean fullParseInformationRequested, IProject project, CancellationToken cancellationToken)
   at ICSharpCode.SharpDevelop.Parser.ParserServiceEntry.DoParse(ITextSource fileContent, IProject parentProject, Boolean fullParseInformationRequested, CancellationToken cancellationToken)
   at ICSharpCode.SharpDevelop.Parser.ParserServiceEntry.Parse(ITextSource fileContent, IProject parentProject, CancellationToken cancellationToken)
   at ICSharpCode.SharpDevelop.Parser.ParserService.Resolve(FileName fileName, TextLocation location, ITextSource fileContent, ICompilation compilation, CancellationToken cancellationToken)
   at ICSharpCode.SharpDevelop.Parser.ParserService.Resolve(ITextEditor editor, TextLocation location, ICompilation compilation, CancellationToken cancellationToken)
   at ICSharpCode.SharpDevelop.Editor.ToolTipRequestEventArgs.get_ResolveResult()
   at ICSharpCode.AvalonEdit.AddIn.XmlDoc.XmlDocTooltipProvider.HandleToolTipRequest(ToolTipRequestEventArgs e)
   at ICSharpCode.SharpDevelop.Editor.ToolTipRequestService.RequestToolTip(ToolTipRequestEventArgs e)
   at ICSharpCode.AvalonEdit.AddIn.CodeEditorView.TextEditorMouseHover(Object sender, MouseEventArgs e)
   at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at ICSharpCode.AvalonEdit.Rendering.TextView.RaiseHoverEventPair(MouseEventArgs e, RoutedEvent tunnelingEvent, RoutedEvent bubblingEvent)
   at ICSharpCode.AvalonEdit.Rendering.TextView.<.ctor>b__0(Object sender, MouseEventArgs e)
   at ICSharpCode.AvalonEdit.Rendering.MouseHoverLogic.OnMouseHover(MouseEventArgs e)
   at ICSharpCode.AvalonEdit.Rendering.MouseHoverLogic.OnMouseHoverTimerElapsed(Object sender, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.