diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs
index 1aebe15285..d9c50036b3 100644
--- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs
+++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs
@@ -81,7 +81,7 @@ namespace Grunwald.BooBinding.CodeCompletion
public ExpressionResult FindExpression(string inText, int offset)
{
offset--; // earlier all ExpressionFinder calls had an inexplicable "cursor - 1".
- // The IExpressionFinder API to use normal cursor offsets, so we need to adjust the offset
+ // The IExpressionFinder API now uses normal cursor offsets, so we need to adjust the offset
// because Boo ExpressionFinder still uses an implementation that expects old offsets
if (inText == null || offset >= inText.Length)
@@ -244,7 +244,7 @@ namespace Grunwald.BooBinding.CodeCompletion
StringBuilder b = new StringBuilder(result.Expression);
// accepting current identifier
int i;
- for (i = offset + 1; i < inText.Length; i++) {
+ for (i = offset; i < inText.Length; i++) {
char c = inText[i];
if (!char.IsLetterOrDigit(c) && c != '_') {
break;
@@ -264,7 +264,7 @@ namespace Grunwald.BooBinding.CodeCompletion
bracketStack.Push(bracket);
} else {
if (bracketStack.Count == 0) {
- b.Append(inText, offset + 1, i - offset - 1);
+ b.Append(inText, offset, i - offset);
result.Expression = b.ToString();
return result;
} else if (c == '\0') {
diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs
index dbf52b818a..28faea108b 100644
--- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs
+++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs
@@ -97,7 +97,7 @@ namespace CSharpBinding
newHandlerCodeBuilder.Append(ambience.Convert(invoke.ReturnType)).Append(" ").Append(newHandlerName);
newHandlerCodeBuilder.Append("(").Append(parameterString.ToString()).AppendLine(")");
newHandlerCodeBuilder.AppendLine("{");
- newHandlerCodeBuilder.Append("throw new NotImplementedException(\"").Append(ResourceService.GetString("CSharpBinding.MethodIsNotImplemented")).AppendLine("\");");
+ newHandlerCodeBuilder.AppendLine("throw new NotImplementedException();");
newHandlerCodeBuilder.Append("}");
// ...and add it to the completionData.
@@ -105,7 +105,7 @@ namespace CSharpBinding
newHandlerTextBuilder.ToString(),
2+newHandlerName.Length,
newHandlerName.Length,
- "new " + eventHandlerFullyQualifiedTypeName + "(" + newHandlerName + ")" +"\n"+ResourceService.GetString("CSharpBinding.GenerateNewHandlerInstructions") + "\n" + CodeCompletionData.GetDocumentation(resolvedClass.Documentation),
+ "new " + eventHandlerFullyQualifiedTypeName + "(" + newHandlerName +StringParser.Parse(")\n${res:CSharpBinding.GenerateNewHandlerInstructions}\n") + CodeCompletionData.GetDocumentation(resolvedClass.Documentation),
resolveResult,
newHandlerCodeBuilder.ToString()
));
diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/CSharpDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/CSharpDesignerGenerator.cs
index 82c8162b58..db05e3b381 100644
--- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/CSharpDesignerGenerator.cs
+++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/CSharpDesignerGenerator.cs
@@ -56,6 +56,11 @@ namespace ICSharpCode.FormsDesigner
protected override int GetCursorLine(ICSharpCode.TextEditor.Document.IDocument document, IMethod method)
{
+ if (document == null)
+ throw new ArgumentNullException("document");
+ if (method == null)
+ throw new ArgumentNullException("method");
+
DomRegion r = method.BodyRegion;
int offset = document.PositionToOffset(new TextLocation(r.BeginColumn - 1, r.BeginLine - 1));
string tmp = document.GetText(offset, 10);
diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
index 8b6f6a320e..69d6d4e461 100644
--- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
+++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
@@ -50,10 +50,12 @@ namespace ICSharpCode.TextEditor.Document
{
#if DEBUG
CheckThread();
+ #endif
+
if (offset < 0 || offset >= Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset < " + Length.ToString());
}
- #endif
+
return offset < gapBeginOffset ? buffer[offset] : buffer[offset + gapLength];
}
@@ -61,13 +63,15 @@ namespace ICSharpCode.TextEditor.Document
{
#if DEBUG
CheckThread();
+ #endif
+
if (offset < 0 || offset > Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString());
}
if (length < 0 || offset + length > Length) {
throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset(" + offset + ")+length <= " + Length.ToString());
}
- #endif
+
int end = offset + length;
if (end < gapBeginOffset) {
@@ -105,13 +109,14 @@ namespace ICSharpCode.TextEditor.Document
#if DEBUG
CheckThread();
+ #endif
+
if (offset < 0 || offset > Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString());
}
if (length < 0 || offset + length > Length) {
throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset+length <= " + Length.ToString());
}
- #endif
// Math.Max is used so that if we need to resize the array
// the new array has enough space for all old chars
diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs
index 1fcaac1ac5..a30add819f 100644
--- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs
+++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs
@@ -100,6 +100,7 @@ namespace ICSharpCode.TextEditor
Controls.Add(this.hScrollBar);
ResizeRedraw = true;
+ Document.TextContentChanged += DocumentTextContentChanged;
Document.DocumentChanged += AdjustScrollBarsOnDocumentChange;
Document.UpdateCommited += AdjustScrollBarsOnCommittedUpdate;
}
@@ -109,6 +110,7 @@ namespace ICSharpCode.TextEditor
if (disposing) {
if (!disposed) {
disposed = true;
+ Document.TextContentChanged -= DocumentTextContentChanged;
Document.DocumentChanged -= AdjustScrollBarsOnDocumentChange;
Document.UpdateCommited -= AdjustScrollBarsOnCommittedUpdate;
motherTextEditorControl = null;
@@ -129,6 +131,14 @@ namespace ICSharpCode.TextEditor
base.Dispose(disposing);
}
+ void DocumentTextContentChanged(object sender, EventArgs e)
+ {
+ // after the text content is changed abruptly, we need to validate the
+ // caret position - otherwise the caret position is invalid for a short amount
+ // of time, which can break client code that expects that the caret position is always valid
+ Caret.ValidateCaretPos();
+ }
+
protected override void OnResize(System.EventArgs e)
{
base.OnResize(e);
diff --git a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
index e721c40a1c..e2218008e0 100644
--- a/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
+++ b/src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
@@ -456,7 +456,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void CheckRemovedOrReplacedFile(object sender, FileEventArgs e)
{
- foreach (OpenedFile file in FileService.OpenedFiles.ToArray()) {
+ foreach (OpenedFile file in FileService.OpenedFiles) {
if (FileUtility.IsBaseDirectory(e.FileName, file.FileName)) {
foreach (IViewContent content in file.RegisteredViewContents.ToArray()) {
content.WorkbenchWindow.CloseWindow(true);
diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs
index 611b35d88e..27aa3b0b95 100644
--- a/src/Main/Base/Project/Src/Services/File/FileService.cs
+++ b/src/Main/Base/Project/Src/Services/File/FileService.cs
@@ -64,10 +64,12 @@ namespace ICSharpCode.SharpDevelop
///
/// Gets a collection containing all currently opened files.
+ /// The returned collection is a read-only copy of the currently opened files -
+ /// it will not reflect future changes of the list of opened files.
///
public static ICollection OpenedFiles {
get {
- return openedFileDict.Values;
+ return openedFileDict.Values.ToArray();
}
}
diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/ExpressionFinder.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/ExpressionFinder.cs
index d4fe8a7ab6..e864638f93 100644
--- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/ExpressionFinder.cs
+++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/ExpressionFinder.cs
@@ -33,7 +33,7 @@ namespace ICSharpCode.SharpDevelop.Dom.VBNet
public string FindExpressionInternal(string inText, int offset)
{
offset--; // earlier all ExpressionFinder calls had an inexplicable "cursor - 1".
- // The IExpressionFinder API to use normal cursor offsets, so we need to adjust the offset
+ // The IExpressionFinder API now uses normal cursor offsets, so we need to adjust the offset
// because VBExpressionFinder still uses an implementation that expects old offsets
this.text = FilterComments(inText, ref offset);