Browse Source

Various bug fixes.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2667 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
2d21efe844
  1. 6
      src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/ExpressionFinder.cs
  2. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/EventHandlerCompletitionDataProvider.cs
  3. 5
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/CSharpDesignerGenerator.cs
  4. 11
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs
  5. 10
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs
  6. 2
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  7. 4
      src/Main/Base/Project/Src/Services/File/FileService.cs
  8. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/VBNet/ExpressionFinder.cs

6
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) public ExpressionResult FindExpression(string inText, int offset)
{ {
offset--; // earlier all ExpressionFinder calls had an inexplicable "cursor - 1". 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 // because Boo ExpressionFinder still uses an implementation that expects old offsets
if (inText == null || offset >= inText.Length) if (inText == null || offset >= inText.Length)
@ -244,7 +244,7 @@ namespace Grunwald.BooBinding.CodeCompletion
StringBuilder b = new StringBuilder(result.Expression); StringBuilder b = new StringBuilder(result.Expression);
// accepting current identifier // accepting current identifier
int i; int i;
for (i = offset + 1; i < inText.Length; i++) { for (i = offset; i < inText.Length; i++) {
char c = inText[i]; char c = inText[i];
if (!char.IsLetterOrDigit(c) && c != '_') { if (!char.IsLetterOrDigit(c) && c != '_') {
break; break;
@ -264,7 +264,7 @@ namespace Grunwald.BooBinding.CodeCompletion
bracketStack.Push(bracket); bracketStack.Push(bracket);
} else { } else {
if (bracketStack.Count == 0) { if (bracketStack.Count == 0) {
b.Append(inText, offset + 1, i - offset - 1); b.Append(inText, offset, i - offset);
result.Expression = b.ToString(); result.Expression = b.ToString();
return result; return result;
} else if (c == '\0') { } else if (c == '\0') {

4
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(ambience.Convert(invoke.ReturnType)).Append(" ").Append(newHandlerName);
newHandlerCodeBuilder.Append("(").Append(parameterString.ToString()).AppendLine(")"); newHandlerCodeBuilder.Append("(").Append(parameterString.ToString()).AppendLine(")");
newHandlerCodeBuilder.AppendLine("{"); newHandlerCodeBuilder.AppendLine("{");
newHandlerCodeBuilder.Append("throw new NotImplementedException(\"").Append(ResourceService.GetString("CSharpBinding.MethodIsNotImplemented")).AppendLine("\");"); newHandlerCodeBuilder.AppendLine("throw new NotImplementedException();");
newHandlerCodeBuilder.Append("}"); newHandlerCodeBuilder.Append("}");
// ...and add it to the completionData. // ...and add it to the completionData.
@ -105,7 +105,7 @@ namespace CSharpBinding
newHandlerTextBuilder.ToString(), newHandlerTextBuilder.ToString(),
2+newHandlerName.Length, 2+newHandlerName.Length,
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, resolveResult,
newHandlerCodeBuilder.ToString() newHandlerCodeBuilder.ToString()
)); ));

5
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) 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; DomRegion r = method.BodyRegion;
int offset = document.PositionToOffset(new TextLocation(r.BeginColumn - 1, r.BeginLine - 1)); int offset = document.PositionToOffset(new TextLocation(r.BeginColumn - 1, r.BeginLine - 1));
string tmp = document.GetText(offset, 10); string tmp = document.GetText(offset, 10);

11
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/TextBufferStrategy/GapTextBufferStrategy.cs

@ -50,10 +50,12 @@ namespace ICSharpCode.TextEditor.Document
{ {
#if DEBUG #if DEBUG
CheckThread(); CheckThread();
#endif
if (offset < 0 || offset >= Length) { if (offset < 0 || offset >= Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset < " + Length.ToString()); throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset < " + Length.ToString());
} }
#endif
return offset < gapBeginOffset ? buffer[offset] : buffer[offset + gapLength]; return offset < gapBeginOffset ? buffer[offset] : buffer[offset + gapLength];
} }
@ -61,13 +63,15 @@ namespace ICSharpCode.TextEditor.Document
{ {
#if DEBUG #if DEBUG
CheckThread(); CheckThread();
#endif
if (offset < 0 || offset > Length) { if (offset < 0 || offset > Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString()); throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString());
} }
if (length < 0 || offset + length > Length) { if (length < 0 || offset + length > Length) {
throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset(" + offset + ")+length <= " + Length.ToString()); throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset(" + offset + ")+length <= " + Length.ToString());
} }
#endif
int end = offset + length; int end = offset + length;
if (end < gapBeginOffset) { if (end < gapBeginOffset) {
@ -105,13 +109,14 @@ namespace ICSharpCode.TextEditor.Document
#if DEBUG #if DEBUG
CheckThread(); CheckThread();
#endif
if (offset < 0 || offset > Length) { if (offset < 0 || offset > Length) {
throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString()); throw new ArgumentOutOfRangeException("offset", offset, "0 <= offset <= " + Length.ToString());
} }
if (length < 0 || offset + length > Length) { if (length < 0 || offset + length > Length) {
throw new ArgumentOutOfRangeException("length", length, "0 <= length, offset+length <= " + Length.ToString()); 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 // Math.Max is used so that if we need to resize the array
// the new array has enough space for all old chars // the new array has enough space for all old chars

10
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs

@ -100,6 +100,7 @@ namespace ICSharpCode.TextEditor
Controls.Add(this.hScrollBar); Controls.Add(this.hScrollBar);
ResizeRedraw = true; ResizeRedraw = true;
Document.TextContentChanged += DocumentTextContentChanged;
Document.DocumentChanged += AdjustScrollBarsOnDocumentChange; Document.DocumentChanged += AdjustScrollBarsOnDocumentChange;
Document.UpdateCommited += AdjustScrollBarsOnCommittedUpdate; Document.UpdateCommited += AdjustScrollBarsOnCommittedUpdate;
} }
@ -109,6 +110,7 @@ namespace ICSharpCode.TextEditor
if (disposing) { if (disposing) {
if (!disposed) { if (!disposed) {
disposed = true; disposed = true;
Document.TextContentChanged -= DocumentTextContentChanged;
Document.DocumentChanged -= AdjustScrollBarsOnDocumentChange; Document.DocumentChanged -= AdjustScrollBarsOnDocumentChange;
Document.UpdateCommited -= AdjustScrollBarsOnCommittedUpdate; Document.UpdateCommited -= AdjustScrollBarsOnCommittedUpdate;
motherTextEditorControl = null; motherTextEditorControl = null;
@ -129,6 +131,14 @@ namespace ICSharpCode.TextEditor
base.Dispose(disposing); 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) protected override void OnResize(System.EventArgs e)
{ {
base.OnResize(e); base.OnResize(e);

2
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -456,7 +456,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void CheckRemovedOrReplacedFile(object sender, FileEventArgs e) 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)) { if (FileUtility.IsBaseDirectory(e.FileName, file.FileName)) {
foreach (IViewContent content in file.RegisteredViewContents.ToArray()) { foreach (IViewContent content in file.RegisteredViewContents.ToArray()) {
content.WorkbenchWindow.CloseWindow(true); content.WorkbenchWindow.CloseWindow(true);

4
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -64,10 +64,12 @@ namespace ICSharpCode.SharpDevelop
/// <summary> /// <summary>
/// Gets a collection containing all currently opened files. /// 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.
/// </summary> /// </summary>
public static ICollection<OpenedFile> OpenedFiles { public static ICollection<OpenedFile> OpenedFiles {
get { get {
return openedFileDict.Values; return openedFileDict.Values.ToArray();
} }
} }

2
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) public string FindExpressionInternal(string inText, int offset)
{ {
offset--; // earlier all ExpressionFinder calls had an inexplicable "cursor - 1". 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 // because VBExpressionFinder still uses an implementation that expects old offsets
this.text = FilterComments(inText, ref offset); this.text = FilterComments(inText, ref offset);

Loading…
Cancel
Save