Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@novell.com>2010-08-22 10:05:52 +0400
committerMike Krüger <mkrueger@novell.com>2010-08-22 10:05:52 +0400
commit7eb0c4dfa521f2a82d4fa4604bfa405e28ec22b1 (patch)
treed39b1c61e53d90b28e0342f1f60e196dc8d8eb6b /main
parent75fe6c9be4bebd27ef8343cbb33535079edb96de (diff)
Transformed text editor line/column coordinate system.
Now any line/column in monodevelop is 1 based.
Diffstat (limited to 'main')
-rw-r--r--main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/HtmlEditorExtension.cs4
-rw-r--r--main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/CompilationUnitVisitor.cs8
-rw-r--r--main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs2
-rw-r--r--main/src/addins/CBinding/Gui/CTextEditorExtension.cs2
-rw-r--r--main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs16
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs23
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Dom/Statements/EmptyStatement.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs12
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs10
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs6
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/CSharpParser.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/NRefactoryParser.cs5
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindMemberAstVisitor.cs21
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryResolver.cs22
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NewCSharpExpressionFinder.cs34
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/ResolveVisitor.cs2
-rw-r--r--main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/TextEditorResolverProvider.cs34
-rw-r--r--main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs10
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs2
-rw-r--r--main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ClassOutlineTextEditorExtension.cs7
-rw-r--r--main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs4
-rw-r--r--main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs2
-rw-r--r--main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/CodeGenerationOptions.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/WriteLineGenerator.cs2
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/CreateBackingStore.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/RemoveBackingStore.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateClass/CreateClassCodeGenerator.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateMethod/CreateMethodCodeGenerator.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.DeclareLocal/DeclareLocalCodeGenerator.cs16
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/ExtractMethodRefactoring.cs8
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/VariableLookupVisitor.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementAbstractMembers.cs2
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementExplicit.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementImplicit.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntegrateTemporaryVariable/IntegrateTemporaryVariableRefactoring.cs14
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceConstant/IntroduceConstantRefactoring.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceFormatItem/IntroduceFormatItemRefactoring.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.MoveTypeToFile/MoveTypeToFileRefactoring.cs10
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/FindTypeReferencesVisitor.cs6
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/RemoveUnusedImportsRefactoring.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/SortImportsRefactoring.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/HelperMethods.cs26
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringOptions.cs8
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs4
-rw-r--r--main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ReferencesFinder.cs2
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueTooltipProvider.cs4
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DefaultFormatter.cs4
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/GotoLineNumberWidget.cs4
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/LanguageItemTooltipProvider.cs8
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs34
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs12
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StatusBox.cs6
-rw-r--r--main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Gui/BaseXmlEditorExtension.cs4
-rw-r--r--main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs12
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs2
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs12
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs8
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor.Utils/Diff.cs6
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViActions.cs18
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViCommandBuilder.cs4
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViMode.cs17
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/BookmarkActions.cs2
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/Caret.cs28
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/CaretMoveActions.cs66
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/ClipboardActions.cs10
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs20
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/DeleteActions.cs15
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/Document.cs80
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/DocumentLocation.cs8
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs8
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs10
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/IconMargin.cs2
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/InsertionCursorEditMode.cs4
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/LineSegment.cs10
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs10
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/Margin.cs2
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/PrimitiveLineSplitter.cs9
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/Selection.cs4
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/SelectionActions.cs5
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditor.cs25
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs8
-rw-r--r--main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs25
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects.CodeGeneration/BaseRefactorer.cs2
-rw-r--r--main/src/core/MonoDevelop.Core/MonoDevelop.Projects/BuildResult.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PathBar.cs1
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs4
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs3
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HiddenTextEditorViewContent.cs6
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs8
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs2
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs6
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveActionTests.cs52
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/DeleteActionTests.cs12
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertNewLineTests.cs6
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertTabTests.cs58
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/RemoveTabTests.cs50
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/SelectionActionTests.cs16
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/DocumentTests.cs12
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/EditActionsTest.cs8
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs6
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/InsertionModeTests.cs1
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/LineSplitterTests.cs24
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/SelectionTests.cs2
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/ViTests.cs59
-rw-r--r--main/tests/UnitTests/Mono.TextEditor.Tests/VirtualSpacesTests.cs12
-rw-r--r--main/tests/UnitTests/MonoDevelop.AspNet/AspNetTesting.cs2
-rw-r--r--main/tests/UnitTests/MonoDevelop.CSharpBinding/CodeCompletionBugTests.cs2
-rw-r--r--main/tests/UnitTests/MonoDevelop.CSharpBinding/FindMemberVisitorTests.cs10
-rw-r--r--main/tests/UnitTests/MonoDevelop.CSharpBinding/ParameterCompletionTests.cs2
-rw-r--r--main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs6
-rw-r--r--main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs4
-rw-r--r--main/tests/UnitTests/MonoDevelop.Refactoring/GenerateNewMemberTests.cs1
118 files changed, 672 insertions, 629 deletions
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/HtmlEditorExtension.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/HtmlEditorExtension.cs
index 5809023e20..53ba521f75 100644
--- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/HtmlEditorExtension.cs
+++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Gui/HtmlEditorExtension.cs
@@ -92,8 +92,8 @@ namespace MonoDevelop.AspNet.Gui
region.End = el.ClosingTag.Region.End;
}
- int s = Editor.Document.LocationToOffset (region.Start.Line - 1, region.Start.Column - 1);
- int e = Editor.Document.LocationToOffset (region.End.Line - 1, region.End.Column - 1);
+ int s = Editor.Document.LocationToOffset (region.Start.Line, region.Start.Column );
+ int e = Editor.Document.LocationToOffset (region.End.Line, region.End.Column);
if (e > s && s > -1)
Editor.SetSelection (s, e);
}
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/CompilationUnitVisitor.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/CompilationUnitVisitor.cs
index e9ba19f2ad..adcc276aa9 100644
--- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/CompilationUnitVisitor.cs
+++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/CompilationUnitVisitor.cs
@@ -80,11 +80,11 @@ namespace MonoDevelop.AspNet.Parser
{
DomRegion region;
if (endLocation == null)
- region = new DomRegion (startLocation.BeginLine, startLocation.BeginColumn + 1,
- startLocation.EndLine, startLocation.EndColumn + 1);
+ region = new DomRegion (startLocation.BeginLine, startLocation.BeginColumn,
+ startLocation.EndLine, startLocation.EndColumn);
else
- region = new DomRegion (startLocation.BeginLine, startLocation.BeginColumn + 1,
- endLocation.EndLine, endLocation.EndColumn + 1);
+ region = new DomRegion (startLocation.BeginLine, startLocation.BeginColumn,
+ endLocation.EndLine, endLocation.EndColumn);
FoldingRegion f = new FoldingRegion (name, region);
regions.Add (f);
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs
index 5eff9dce84..fe763f3491 100644
--- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs
+++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs
@@ -365,7 +365,7 @@ namespace MonoDevelop.AspNet.Parser
Doc.Info.RegisteredTags.Add (directive);
var line = Math.Max (node.Location.EndLine, node.Location.BeginLine);
- var pos = editor.Document.LocationToOffset (line - 1, editor.Document.GetLine (line - 2).EditableLength);
+ var pos = editor.Document.LocationToOffset (line, editor.Document.GetLine (line - 1).EditableLength);
if (pos < 0)
return;
diff --git a/main/src/addins/CBinding/Gui/CTextEditorExtension.cs b/main/src/addins/CBinding/Gui/CTextEditorExtension.cs
index d0ed1995e0..0ca4fc0408 100644
--- a/main/src/addins/CBinding/Gui/CTextEditorExtension.cs
+++ b/main/src/addins/CBinding/Gui/CTextEditorExtension.cs
@@ -216,7 +216,7 @@ namespace CBinding
public override ICompletionDataList HandleCodeCompletion (
CodeCompletionContext completionContext, char completionChar)
{
- string lineText = Editor.GetLineText (completionContext.TriggerLine - 1).TrimEnd();
+ string lineText = Editor.GetLineText (completionContext.TriggerLine).TrimEnd();
// If the line ends with a matched extension, invoke its handler
foreach (KeyValuePair<string, GetMembersForExtension> pair in completionExtensions) {
diff --git a/main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs b/main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs
index 57ca9a213e..34d38f6b66 100644
--- a/main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs
+++ b/main/src/addins/CSharpBinding/AspNet/AspLanguageBuilder.cs
@@ -157,8 +157,8 @@ namespace MonoDevelop.CSharp.Completion
codeCompletionContext = new CodeCompletionContext () {
TriggerOffset = localInfo.CaretPosition,
- TriggerLine = documentLocation.Line + 1,
- TriggerLineOffset = documentLocation.Column + 1,
+ TriggerLine = documentLocation.Line,
+ TriggerLineOffset = documentLocation.Column - 1
};
var r = new System.IO.StringReader (localInfo.LocalDocument);
@@ -219,8 +219,8 @@ namespace MonoDevelop.CSharp.Completion
CodeCompletionContext result = new CodeCompletionContext ();
result.TriggerOffset = triggerOffset;
DocumentLocation loc = localInfo.HiddenDocument.Editor.Document.OffsetToLocation (triggerOffset);
- result.TriggerLine = loc.Line + 1;
- result.TriggerLineOffset = loc.Column + 1;
+ result.TriggerLine = loc.Line;
+ result.TriggerLineOffset = loc.Column - 1;
result.TriggerXCoord = savedCtx.TriggerXCoord;
result.TriggerYCoord = savedCtx.TriggerYCoord;
@@ -248,8 +248,8 @@ namespace MonoDevelop.CSharp.Completion
int offset = localInfo.OriginalCaretPosition + ctx.TriggerOffset - localInfo.CaretPosition;
translatedCtx.TriggerOffset = offset;
DocumentLocation loc = localInfo.HiddenDocument.Editor.Document.OffsetToLocation (offset);
- translatedCtx.TriggerLine = loc.Line + 1;
- translatedCtx.TriggerLineOffset = loc.Column + 1;
+ translatedCtx.TriggerLine = loc.Line;
+ translatedCtx.TriggerLineOffset = loc.Column - 1;
translatedCtx.TriggerWordLength = ctx.TriggerWordLength;
realDocument.GetContent <ICompletionWidget> ().SetCompletionText (translatedCtx, partial_word, complete_word, wordOffset);
}
@@ -282,8 +282,8 @@ namespace MonoDevelop.CSharp.Completion
WriteClassDeclaration (info, document);
foreach (var node in info.ScriptBlocks) {
- int start = data.Document.LocationToOffset (node.Location.EndLine - 1, node.Location.EndColumn);
- int end = data.Document.LocationToOffset (node.EndLocation.BeginLine - 1, node.EndLocation.BeginColumn);
+ int start = data.Document.LocationToOffset (node.Location.EndLine, node.Location.EndColumn);
+ int end = data.Document.LocationToOffset (node.EndLocation.BeginLine, node.EndLocation.BeginColumn);
document.AppendLine (data.Document.GetTextBetween (start, end));
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs
index 2abee34530..cb4e79e6ac 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpTextEditorCompletion.cs
@@ -220,7 +220,7 @@ namespace MonoDevelop.CSharp.Completion
cursor = textEditorData.IsSomethingSelected ? textEditorData.SelectionRange.Offset : textEditorData.Caret.Offset;
if (stateTracker.Engine.IsInsideDocLineComment) {
- string lineText = textEditorData.GetLineText (completionContext.TriggerLine - 1);
+ string lineText = textEditorData.GetLineText (completionContext.TriggerLine);
int startIndex = Math.Min (completionContext.TriggerLineOffset - 1, lineText.Length - 1);
while (startIndex >= 0 && lineText[startIndex] != '<') {
@@ -293,7 +293,7 @@ namespace MonoDevelop.CSharp.Completion
break;
if (stateTracker.Engine.IsInsideDocLineComment) {
- string lineText = textEditorData.GetLineText (completionContext.TriggerLine - 1);
+ string lineText = textEditorData.GetLineText (completionContext.TriggerLine);
bool startsDocComment = true;
int slashes = 0;
for (int i = 0; i < completionContext.TriggerLineOffset && i < lineText.Length; i++) {
@@ -340,7 +340,7 @@ namespace MonoDevelop.CSharp.Completion
ParsedDocument currentParsedDocument = Document.UpdateParseDocument ();
IType insideClass = NRefactoryResolver.GetTypeAtCursor (currentParsedDocument.CompilationUnit, Document.FileName, location);
if (insideClass != null) {
- string indent = textEditorData.Document.GetLineIndent (completionContext.TriggerLine - 1);
+ string indent = textEditorData.Document.GetLineIndent (completionContext.TriggerLine);
if (insideClass.ClassType == ClassType.Delegate) {
AppendSummary (generatedComment, indent, out newCursorOffset);
IMethod m = null;
@@ -359,7 +359,7 @@ namespace MonoDevelop.CSharp.Completion
}
}
if (generateStandardComment) {
- string indent = textEditorData.Document.GetLineIndent (completionContext.TriggerLine - 1);
+ string indent = textEditorData.Document.GetLineIndent (completionContext.TriggerLine);
AppendSummary (generatedComment, indent, out newCursorOffset);
}
textEditorData.Document.EndAtomicUndo ();
@@ -523,7 +523,7 @@ namespace MonoDevelop.CSharp.Completion
sb.Append (", ");
IType parameterType = dom.GetType (delegateMethod.Parameters[k].ReturnType);
IReturnType returnType = parameterType != null ? new DomReturnType (parameterType) : delegateMethod.Parameters[k].ReturnType;
- sb.Append (CompletionDataCollector.ambience.GetString (Document.CompilationUnit.ShortenTypeName (returnType, textEditorData.Caret.Line + 1, textEditorData.Caret.Column + 1), OutputFlags.ClassBrowserEntries | OutputFlags.UseFullName | OutputFlags.UseFullInnerTypeName));
+ sb.Append (CompletionDataCollector.ambience.GetString (Document.CompilationUnit.ShortenTypeName (returnType, textEditorData.Caret.Line, textEditorData.Caret.Column), OutputFlags.ClassBrowserEntries | OutputFlags.UseFullName | OutputFlags.UseFullInnerTypeName));
sb.Append (" ");
sb.Append (delegateMethod.Parameters[k].Name);
}
@@ -693,9 +693,9 @@ namespace MonoDevelop.CSharp.Completion
int GetMemberStartPosition (IMember mem)
{
if (mem is IField)
- return textEditorData.Document.LocationToOffset (mem.Location.Line - 1, mem.Location.Column - 1);
+ return textEditorData.Document.LocationToOffset (mem.Location.Line, mem.Location.Column);
if (mem != null)
- return textEditorData.Document.LocationToOffset (mem.BodyRegion.Start.Line - 1, mem.BodyRegion.Start.Column - 1);
+ return textEditorData.Document.LocationToOffset (mem.BodyRegion.Start.Line, mem.BodyRegion.Start.Column);
return 0;
}
@@ -704,8 +704,7 @@ namespace MonoDevelop.CSharp.Completion
// Start calculating the parameter offset from the beginning of the
// current member, instead of the beginning of the file.
cpos = textEditorData.Caret.Offset - 1;
- IMember mem = Document.ParsedDocument.CompilationUnit.GetMemberAt (textEditorData.Caret.Line + 1, textEditorData.Caret.Column + 1);
- Console.WriteLine ("member:" + mem);
+ IMember mem = Document.ParsedDocument.CompilationUnit.GetMemberAt (textEditorData.Caret.Line, textEditorData.Caret.Column);
if (mem == null || (mem is IType))
return false;
int startPos = GetMemberStartPosition (mem);
@@ -2290,8 +2289,8 @@ namespace MonoDevelop.CSharp.Completion
return;
var loc = textEditorData.Caret.Location;
- IType type = Document.ParsedDocument.CompilationUnit.GetTypeAt (loc.Line + 1, loc.Column + 1);
- IMember member = type != null && type.ClassType != ClassType.Delegate ? type.GetMemberAt (loc.Line + 1, loc.Column + 1) : null;
+ IType type = Document.ParsedDocument.CompilationUnit.GetTypeAt (loc.Line, loc.Column);
+ IMember member = type != null && type.ClassType != ClassType.Delegate ? type.GetMemberAt (loc.Line, loc.Column) : null;
List<PathEntry> result = new List<PathEntry> ();
var amb = GetAmbience ();
@@ -2301,7 +2300,7 @@ namespace MonoDevelop.CSharp.Completion
if (node is ICompilationUnit) {
if (!Document.ParsedDocument.UserRegions.Any ())
break;
- FoldingRegion reg = Document.ParsedDocument.UserRegions.Where (r => r.Region.Contains (loc.Line + 1, loc.Column + 1)).LastOrDefault ();
+ FoldingRegion reg = Document.ParsedDocument.UserRegions.Where (r => r.Region.Contains (loc.Line, loc.Column)).LastOrDefault ();
if (reg == null) {
entry = new PathEntry (GettextCatalog.GetString ("No region"));
} else {
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
index 404fef698e..b46c0b1d4c 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/EventCreationCompletionData.cs
@@ -76,7 +76,7 @@ namespace MonoDevelop.CSharp.Completion
editor.Replace (initialOffset, editor.Caret.Offset - initialOffset, this.DisplayText + ";");
// Search opening bracket of member
- int pos = callingMember != null ? editor.Document.LocationToOffset (callingMember.BodyRegion.Start.Line - 1, callingMember.BodyRegion.Start.Column - 1) : initialOffset;
+ int pos = callingMember != null ? editor.Document.LocationToOffset (callingMember.BodyRegion.Start.Line, callingMember.BodyRegion.Start.Column) : initialOffset;
while (pos < editor.Document.Length && editor.Document.GetCharAt (pos) != '{') {
pos++;
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Dom/Statements/EmptyStatement.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Dom/Statements/EmptyStatement.cs
index 24e6b90477..021ad15576 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Dom/Statements/EmptyStatement.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Dom/Statements/EmptyStatement.cs
@@ -43,7 +43,7 @@ namespace MonoDevelop.CSharp.Dom
}
public override DomLocation EndLocation {
get {
- return new DomLocation (Location.Line, Location.Column + 1);
+ return new DomLocation (Location.Line, Location.Column);
}
}
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs
index 4052987e5d..d157e47527 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpFormatter.cs
@@ -71,7 +71,7 @@ namespace MonoDevelop.CSharp.Formatting
return "";
}
StringBuilder result = new StringBuilder ();
- int offset = data.Document.LocationToOffset (member.Location.Line - 1, 0);
+ int offset = data.Document.LocationToOffset (member.Location.Line, 1);
int start = offset;
while (offset < data.Document.Length && data.Document.GetCharAt (offset) != '{') {
offset++;
@@ -252,7 +252,7 @@ namespace MonoDevelop.CSharp.Formatting
if (formatter.hasErrors)
return;
- int startPos = data.Document.LocationToOffset (member.Location.Line - 1, 0) - 1;
+ int startPos = data.Document.LocationToOffset (member.Location.Line, 1) - 1;
InFormat = true;
if (member != type) {
int len1 = formattedText.IndexOf ('{') + 1;
@@ -272,11 +272,11 @@ namespace MonoDevelop.CSharp.Formatting
}
//Console.WriteLine ("Indent:" + GetIndent (data, member.Location.Line - 1).Replace ("\t", "->").Replace (" ", "°"));
//Console.WriteLine ("formattedText1:" + formattedText.Replace ("\t", "->").Replace (" ", "°"));
- formattedText = AddIndent (formattedText, GetIndent (data, member.Location.Line - 1));
+ formattedText = AddIndent (formattedText, GetIndent (data, member.Location.Line));
Document doc = new Document ();
doc.Text = formattedText;
- for (int i = doc.LineCount - 1; i >= 0; i--) {
+ for (int i = doc.LineCount; i --> DocumentLocation.MinLine;) {
LineSegment lineSegment = doc.GetLine (i);
if (doc.IsEmptyLine (lineSegment))
((IBuffer)doc).Remove (lineSegment.Offset, lineSegment.Length);
@@ -492,8 +492,8 @@ namespace MonoDevelop.CSharp.Formatting
static int GetNextTabstop (int currentColumn, int tabSize)
{
- int result = currentColumn + tabSize;
- return (result / tabSize) * tabSize;
+ int result = currentColumn - 1 + tabSize;
+ return 1 + (result / tabSize) * tabSize;
}
public static void SetFormatOptions (CSharpOutputVisitor outputVisitor, PolicyContainer policyParent)
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
index 4c85edd79b..cc14deedba 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpTextEditorIndentation.cs
@@ -136,11 +136,11 @@ namespace MonoDevelop.CSharp.Formatting
this.data = data;
this.stateTracker = stateTracker;
}
-
+
public string GetVirtualSpaces (int lineNumber, int column)
{
string indent = GetIndent (lineNumber, column);
- if (column == indent.Length)
+ if (column == indent.Length + 1)
return data.FormatString (0, indent);
return "";
}
@@ -153,8 +153,8 @@ namespace MonoDevelop.CSharp.Formatting
public int GetNextVirtualColumn (int lineNumber, int column)
{
- if (column == 0) {
- int result = GetIndent (lineNumber, column).Length;
+ if (column == DocumentLocation.MinColumn) {
+ int result = GetIndent (lineNumber, column).Length + 1;
return result;
}
return column;
@@ -454,7 +454,7 @@ namespace MonoDevelop.CSharp.Formatting
bool FixLineStart (int lineNumber)
{
- if (lineNumber > 0) {
+ if (lineNumber > DocumentLocation.MinLine) {
LineSegment line = textEditorData.Document.GetLine (lineNumber);
int insertionPoint = line.Offset + line.GetIndentation (textEditorData.Document).Length;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
index b82006b27e..24f2afe1a8 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Highlighting/HighlightUsagesExtension.cs
@@ -157,14 +157,14 @@ namespace MonoDevelop.CSharp.Highlighting
if (references != null) {
bool alphaBlend = false;
foreach (var r in references) {
- UsageMarker marker = GetMarker (r.Line - 1);
- int offset = textEditorData.Document.LocationToOffset (r.Line - 1, r.Column - 1);
+ UsageMarker marker = GetMarker (r.Line);
+ int offset = textEditorData.Document.LocationToOffset (r.Line, r.Column);
if (!alphaBlend && textEditorData.Parent.TextViewMargin.SearchResults.Any (sr => sr.Contains (offset) || sr.Contains (offset + r.Name.Length) ||
offset < sr.Offset && sr.EndOffset < offset + r.Name.Length)) {
textEditorData.Parent.TextViewMargin.AlphaBlendSearchResults = alphaBlend = true;
}
marker.Usages.Add (new Mono.TextEditor.Segment (offset, r.Name.Length));
- lineNumbers.Add (r.Line - 1);
+ lineNumbers.Add (r.Line);
}
}
foreach (int line in lineNumbers)
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/CSharpParser.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/CSharpParser.cs
index fef3074ad1..c9380870ba 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/CSharpParser.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/CSharpParser.cs
@@ -63,7 +63,7 @@ namespace MonoDevelop.CSharp.Parser
public static DomLocation Convert (Mono.CSharp.Location loc)
{
- return new DomLocation (loc.Row - 1, loc.Column - 1);
+ return new DomLocation (loc.Row, loc.Column);
}
#region Global
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/NRefactoryParser.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/NRefactoryParser.cs
index 6b2f5ad43b..bd510c462b 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/NRefactoryParser.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Parser/NRefactoryParser.cs
@@ -376,7 +376,7 @@ namespace MonoDevelop.CSharp.Parser
newType.Location = ConvertLocation (typeDeclaration.StartLocation);
newType.ClassType = ConvertClassType (typeDeclaration.Type);
DomRegion region = ConvertRegion (typeDeclaration.BodyStartLocation, typeDeclaration.EndLocation);
- region.End = new DomLocation (region.End.Line, region.End.Column + 1);
+ region.End = new DomLocation (region.End.Line, region.End.Column);
newType.BodyRegion = region;
newType.Modifiers = ConvertModifiers (typeDeclaration.Modifier);
@@ -558,7 +558,8 @@ namespace MonoDevelop.CSharp.Parser
return null;
}
-
+
+
static string GetOperatorName (ICSharpCode.NRefactory.Ast.OperatorDeclaration operatorDeclaration)
{
if (operatorDeclaration == null)
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindMemberAstVisitor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindMemberAstVisitor.cs
index eba07278de..7580bc3ed8 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindMemberAstVisitor.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/FindMemberAstVisitor.cs
@@ -326,9 +326,10 @@ namespace MonoDevelop.CSharp.Refactoring
MemberReference CreateReference (int line, int col, string name)
{
- int pos = text.LocationToOffset (line - 1, col - 1);
- int spos = text.LocationToOffset (line - 1, 0);
- int epos = text.LocationToOffset (line, 0);
+ Console.WriteLine ("create ref: "+ line +"/"+ col + name);
+ int pos = text.LocationToOffset (line, col);
+ int spos = text.LocationToOffset (line, 1);
+ int epos = text.LocationToOffset (line + 1, 1);
if (epos == -1) epos = text.Length - 1;
string txt;
@@ -393,7 +394,7 @@ namespace MonoDevelop.CSharp.Refactoring
bool SearchText (string text, int startLine, int startColumn, out int line, out int column)
{
- int position = this.text.LocationToOffset (startLine - 1, startColumn - 1);
+ int position = this.text.LocationToOffset (startLine, startColumn);
line = column = -1;
if (position < 0)
return false;
@@ -405,8 +406,8 @@ namespace MonoDevelop.CSharp.Refactoring
(position + searchedMemberName.Length >= this.text.Length || !IsIdentifierPart (this.text.GetCharAt (position + searchedMemberName.Length))) &&
(this.text.GetTextAt (position, searchedMemberName.Length) == searchedMemberName)) {
var location = this.text.OffsetToLocation (position);
- line = location.Line + 1;
- column = location.Column + 1;
+ line = location.Line;
+ column = location.Column;
return true;
}
position ++;
@@ -416,7 +417,7 @@ namespace MonoDevelop.CSharp.Refactoring
bool IsSearchTextAt (int startLine, int startColumn)
{
- int position = this.text.LocationToOffset (startLine - 1, startColumn - 1);
+ int position = this.text.LocationToOffset (startLine, startColumn);
if ((position == 0 || !IsIdentifierPart (this.text.GetCharAt (position - 1))) &&
(position + searchedMemberName.Length >= this.text.Length || !IsIdentifierPart (this.text.GetCharAt (position + searchedMemberName.Length))) &&
@@ -471,7 +472,7 @@ namespace MonoDevelop.CSharp.Refactoring
if (((IType)this.searchedMember).Parts.Any (t => t.CompilationUnit.FileName == fileName) &&
((IType)this.searchedMember).FullName == CurrentTypeFullName &&
((IType)this.searchedMember).TypeParameters.Count == typeStack.Peek ().Templates.Count &&
- IsSearchTextAt (destructorDeclaration.StartLocation.Line, destructorDeclaration.StartLocation.Column + 1))
+ IsSearchTextAt (destructorDeclaration.StartLocation.Line, destructorDeclaration.StartLocation.Column + 1)) // need to skip the '~'
AddUniqueReference (destructorDeclaration.StartLocation.Line, destructorDeclaration.StartLocation.Column + 1, this.searchedMemberName);
}
@@ -718,8 +719,8 @@ namespace MonoDevelop.CSharp.Refactoring
}
IType cls = resolveResult != null ? resolver.Dom.GetType (resolveResult.ResolvedType) : null;
if (cls != null) {
- int pos = text.LocationToOffset (fieldExp.StartLocation.Y - 1, fieldExp.StartLocation.X - 1);
- int endpos = text.LocationToOffset (fieldExp.EndLocation.Y - 1, fieldExp.EndLocation.X - 1);
+ int pos = text.LocationToOffset (fieldExp.StartLocation.Y, fieldExp.StartLocation.X);
+ int endpos = text.LocationToOffset (fieldExp.EndLocation.Y, fieldExp.EndLocation.X);
string txt = text.GetTextBetween (pos, endpos);
if (txt == searchedMemberName) {
int line, column;
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryResolver.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryResolver.cs
index 5cd6ab2b3c..fead94d5b7 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryResolver.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NRefactoryResolver.cs
@@ -206,7 +206,7 @@ namespace MonoDevelop.CSharp.Resolver
parser.Parse ();
lookupTableVisitor.VisitCompilationUnit (parser.CompilationUnit, null);
memberCompilationUnit = parser.CompilationUnit;
- lookupVariableLine = editor.Caret.Line - 1;
+ lookupVariableLine = editor.Caret.Line - 2;
setupLookupTableVisitor = true;
}
}
@@ -310,7 +310,7 @@ namespace MonoDevelop.CSharp.Resolver
if (CallingMember is IProperty) {
IProperty property = (IProperty)callingMember;
- if (property.HasSet && editor != null && property.SetRegion.Contains (resolvePosition.Line, editor.Caret.Column + 1))
+ if (property.HasSet && editor != null && property.SetRegion.Contains (resolvePosition.Line, editor.Caret.Column))
col.Add ("value");
}
@@ -604,7 +604,7 @@ namespace MonoDevelop.CSharp.Resolver
if (!lambda.ExpressionBody.IsNull) {
DomLocation old = resolver.resolvePosition;
try {
- resolver.resolvePosition = new DomLocation ((resolver.CallingMember != null ? resolver.CallingMember.Location.Line : 0) +
+ resolver.resolvePosition = new DomLocation ((resolver.CallingMember != null ? resolver.CallingMember.Location.Line : 0) +
lambda.ExpressionBody.StartLocation.Line - 2,
lambda.ExpressionBody.StartLocation.Column - 1);
lambdaReturnType = visitor.Resolve (lambda.ExpressionBody);
@@ -713,14 +713,15 @@ namespace MonoDevelop.CSharp.Resolver
if (resultTable.TryGetValue (identifier, out result))
return result;
resultTable[identifier] = result;
+// Console.WriteLine ("lookup: " + identifier);
// Console.WriteLine (lookupVariableLine);
foreach (KeyValuePair<string, List<LocalLookupVariable>> pair in this.lookupTableVisitor.Variables) {
if (identifier == pair.Key) {
LocalLookupVariable var = null;
// Console.WriteLine ("--- RP:" + this.resolvePosition + "/" + pair.Value.Count);
foreach (LocalLookupVariable v2 in pair.Value) {
- DomLocation varStartPos = new DomLocation (lookupVariableLine + v2.StartPos.Line, v2.StartPos.Column - 1);
- DomLocation varEndPos = new DomLocation (lookupVariableLine + v2.EndPos.Line, v2.EndPos.Column - 1);
+ DomLocation varStartPos = new DomLocation (lookupVariableLine + v2.StartPos.Line, v2.StartPos.Column);
+ DomLocation varEndPos = new DomLocation (lookupVariableLine + v2.EndPos.Line, v2.EndPos.Column);
// Console.WriteLine (v2.Name + ":" + varStartPos + " <> " + varEndPos + " resolve position:" + this.resolvePosition);
if (varStartPos > this.resolvePosition || (!v2.EndPos.IsEmpty && varEndPos < this.resolvePosition))
continue;
@@ -768,7 +769,7 @@ namespace MonoDevelop.CSharp.Resolver
}
if (var.Initializer != null) {
ResolveResult initializerResolve = visitor.Resolve (var.Initializer);
-// Console.WriteLine ("initializer : "+ var.Initializer + " result:" + initializerResolve);
+// Console.WriteLine ("initializer : "+ var.Initializer + " result:" + initializerResolve + " isloopvar: " +var.IsLoopVariable);
varType = var.IsLoopVariable ? DomType.GetComponentType (dom, initializerResolve.ResolvedType) : initializerResolve.ResolvedType;
varTypeUnresolved = var.IsLoopVariable ? DomType.GetComponentType (dom, initializerResolve.UnresolvedType) : initializerResolve.UnresolvedType;
// Console.WriteLine ("resolved type:" + initializerResolve.ResolvedType + " is loop : " + var.IsLoopVariable);
@@ -779,6 +780,7 @@ namespace MonoDevelop.CSharp.Resolver
varTypeUnresolved = varType = ConvertTypeReference (var.TypeRef);
}
varType = ResolveType (varType);
+ Console.WriteLine (identifier + ":" + varType);
result = new LocalVariableResolveResult (
new LocalVariable (CallingMember, identifier, varType,
new DomRegion (lookupVariableLine + var.StartPos.Line, var.StartPos.Column,
@@ -794,7 +796,7 @@ namespace MonoDevelop.CSharp.Resolver
// special handling of property or field return types, they can have the same name as the return type
// ex.: MyType MyType { get; set; } Type1 Type1;
if ((callingMember is IProperty || callingMember is IField) && identifier == callingMember.Name) {
- int pos = editor.Document.LocationToOffset (resolvePosition.Line - 1, resolvePosition.Column - 1);
+ int pos = editor.Document.LocationToOffset (resolvePosition.Line, resolvePosition.Column);
while (pos < editor.Length && !Char.IsWhiteSpace (editor.GetCharAt (pos)))
pos++;
while (pos < editor.Length && Char.IsWhiteSpace (editor.GetCharAt (pos)))
@@ -921,18 +923,18 @@ namespace MonoDevelop.CSharp.Resolver
if (member == null)
return "";
StringBuilder result = new StringBuilder ();
- int startLine = member.Location.Line - 1;
+ int startLine = member.Location.Line;
int endLine = member.BodyRegion.End.Line < startLine ? startLine : member.BodyRegion.End.Line;
string text;
result.Append ("class ");
result.Append (member.DeclaringType.Name);
result.Append ("{");
result.Append (editor.EolMarker);
- endLine = Math.Min (endLine, editor.Document.LineCount - 1);
+ endLine = Math.Min (endLine, editor.Document.LineCount);
int endPos = editor.Document.GetLine (endLine).EndOffset;
if (endPos < 0)
endPos = editor.Length;
- int startPos = Math.Max (0, editor.Document.LocationToOffset (startLine, 0));
+ int startPos = Math.Max (1, editor.Document.LocationToOffset (startLine, 1));
text = editor.GetTextBetween (startPos, endPos);
if (!string.IsNullOrEmpty (text))
result.Append (text);
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NewCSharpExpressionFinder.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NewCSharpExpressionFinder.cs
index 2fcc0d4a25..b0abe89037 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NewCSharpExpressionFinder.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/NewCSharpExpressionFinder.cs
@@ -260,7 +260,7 @@ namespace MonoDevelop.CSharp.Resolver
if (lhsExpr.Expression != null) {
NRefactoryResolver resolver = new NRefactoryResolver (projectContent, unit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName);
- ResolveResult rr = resolver.Resolve (lhsExpr, new DomLocation (editor.Caret.Line + 1, editor.Caret.Column + 1));
+ ResolveResult rr = resolver.Resolve (lhsExpr, new DomLocation (editor.Caret.Line, editor.Caret.Column));
//ResolveResult rr = ParserService.Resolve (lhsExpr, currentLine.LineNumber, pos, editor.FileName, editor.Text);
if (rr != null && rr.ResolvedType != null) {
@@ -338,7 +338,7 @@ namespace MonoDevelop.CSharp.Resolver
if (lhsExpr.Expression != null) {
NRefactoryResolver resolver = new NRefactoryResolver (projectContent, unit, ICSharpCode.NRefactory.SupportedLanguage.CSharp, editor, fileName);
- ResolveResult rr = resolver.Resolve (lhsExpr, new DomLocation (editor.Caret.Line + 1, editor.Caret.Column + 1));
+ ResolveResult rr = resolver.Resolve (lhsExpr, new DomLocation (editor.Caret.Line, editor.Caret.Column));
//ResolveResult rr = ParserService.Resolve (lhsExpr, currentLine.LineNumber, pos, editor.FileName, editor.Text);
if (rr != null && rr.ResolvedType != null) {
@@ -362,7 +362,7 @@ namespace MonoDevelop.CSharp.Resolver
/*LanguageProperties.CSharp.CodeGenerator.GenerateCode(
CodeGenerator.ConvertType(
rr.ResolvedType,
- new ClassFinder(ParserService.GetParseInformation(editor.FileName), editor.ActiveTextAreaControl.Caret.Line + 1, editor.ActiveTextAreaControl.Caret.Column + 1)
+ new ClassFinder(ParserService.GetParseInformation(editor.FileName), editor.ActiveTextAreaControl.Caret.Line, editor.ActiveTextAreaControl.Caret.Column)
), "");*/ if (suggestedClassName != c.Name) {
// create an IType instance that includes the type arguments in its name
//context.DefaultItem = new RenamedClass (c, suggestedClassName);
@@ -671,7 +671,7 @@ namespace MonoDevelop.CSharp.Resolver
lexer = ParserFactory.CreateLexer (SupportedLanguage.CSharp, editor.Document.OpenTextReader ());
lexer.SkipAllComments = true;
var loc = editor.Document.OffsetToLocation (offset);
- targetPosition = new Location (loc.Column + 1, loc.Line + 1);
+ targetPosition = new Location (loc.Column, loc.Line);
frame = new Frame ();
lastToken = Tokens.EOF;
@@ -720,9 +720,9 @@ namespace MonoDevelop.CSharp.Resolver
if (token == null || token.Kind == Tokens.EOF)
tokenOffset = editor.Length;
else
- tokenOffset = editor.Document.LocationToOffset (token.Location.Line - 1, token.Location.Column - 1);
- int lastExpressionStartOffset = editor.Document.LocationToOffset (frame.lastExpressionStart.Line - 1, frame.lastExpressionStart.Column - 1);
- if (lastExpressionStartOffset >= 0) {
+ tokenOffset = editor.Document.LocationToOffset (token.Location.Line, token.Location.Column);
+ if (!frame.lastExpressionStart.IsEmpty) {
+ int lastExpressionStartOffset = editor.Document.LocationToOffset (frame.lastExpressionStart.Line, frame.lastExpressionStart.Column);
if (offset < tokenOffset) {
// offset is in front of this token
return MakeResult (editor, lastExpressionStartOffset, tokenOffset, frame.contexts);
@@ -786,7 +786,7 @@ namespace MonoDevelop.CSharp.Resolver
}
break;
case Tokens.From:
- frame.SetContext (new ExpressionContext.LinqContext (token.Location.Line - 1, token.Location.Column - 1));
+ frame.SetContext (new ExpressionContext.LinqContext (token.Location.Line, token.Location.Column));
break;
case Tokens.LessThan:
if (Tokens.ValidInsideTypeName[lastToken]) {
@@ -1082,11 +1082,11 @@ namespace MonoDevelop.CSharp.Resolver
if (targetPosition < token.Location) {
resultFrame = frame;
resultContext = frame.context;
- resultStartOffset = editor.Document.LocationToOffset (frame.lastExpressionStart.Line - 1, frame.lastExpressionStart.Column - 1);
- alternateResultStartOffset = editor.Document.LocationToOffset (frame.lastNewTokenStart.Line - 1, frame.lastNewTokenStart.Column - 1);
+ resultStartOffset = frame.lastExpressionStart.IsEmpty ? -1 : editor.Document.LocationToOffset (frame.lastExpressionStart.Line, frame.lastExpressionStart.Column);
+ alternateResultStartOffset = frame.lastNewTokenStart.IsEmpty ? -1 : editor.Document.LocationToOffset (frame.lastNewTokenStart.Line, frame.lastNewTokenStart.Column);
if (resultStartOffset < 0)
break;
- resultEndOffset = editor.Document.LocationToOffset (token.Location.Line - 1, token.Location.Column - 1);
+ resultEndOffset = editor.Document.LocationToOffset (token.Location.Line, token.Location.Column);
state = SEARCHING_END;
}
}
@@ -1096,15 +1096,15 @@ namespace MonoDevelop.CSharp.Resolver
if (targetPosition < token.EndLocation) {
resultFrame = frame;
resultContext = prevContext;
- resultStartOffset = editor.Document.LocationToOffset (frame.lastExpressionStart.Line - 1, frame.lastExpressionStart.Column - 1);
- alternateResultStartOffset = editor.Document.LocationToOffset (frame.lastNewTokenStart.Line - 1, frame.lastNewTokenStart.Column - 1);
- resultEndOffset = editor.Document.LocationToOffset (token.EndLocation.Line - 1, token.EndLocation.Column - 1);
+ resultStartOffset = frame.lastExpressionStart.IsEmpty ? -1 : editor.Document.LocationToOffset (frame.lastExpressionStart.Line, frame.lastExpressionStart.Column);
+ alternateResultStartOffset = frame.lastNewTokenStart.IsEmpty ? -1 : editor.Document.LocationToOffset (frame.lastNewTokenStart.Line, frame.lastNewTokenStart.Column);
+ resultEndOffset = token.EndLocation.IsEmpty ? -1 : editor.Document.LocationToOffset (token.EndLocation.Line, token.EndLocation.Column);
if (resultStartOffset < 0)
break;
state = SEARCHING_END;
}
} else if (state == SEARCHING_END) {
- int lastExpressionStartOffset = editor.Document.LocationToOffset (resultFrame.lastExpressionStart.Line - 1, resultFrame.lastExpressionStart.Column - 1);
+ int lastExpressionStartOffset = resultFrame.lastExpressionStart.IsEmpty ? -1 : editor.Document.LocationToOffset (resultFrame.lastExpressionStart.Line, resultFrame.lastExpressionStart.Column);
if (lastExpressionStartOffset == alternateResultStartOffset && alternateResultStartOffset >= 0)
resultStartOffset = lastExpressionStartOffset;
if (resultFrame.type == FrameType.Popped || lastExpressionStartOffset != resultStartOffset || token.Kind == Tokens.Dot || token.Kind == Tokens.DoubleColon) {
@@ -1123,7 +1123,7 @@ namespace MonoDevelop.CSharp.Resolver
}
} else {
if (frame.bracketType != '<') {
- resultEndOffset = editor.Document.LocationToOffset (token.EndLocation.Line - 1, token.EndLocation.Column - 1);
+ resultEndOffset = token.EndLocation.IsEmpty ? -1 : editor.Document.LocationToOffset (token.EndLocation.Line, token.EndLocation.Column);
}
}
}
@@ -1142,7 +1142,7 @@ namespace MonoDevelop.CSharp.Resolver
}
var start = editor.Document.OffsetToLocation (startOffset);
var end = editor.Document.OffsetToLocation (endOffset);
- return new ExpressionResult (editor.GetTextBetween (startOffset, endOffset), new DomRegion (start.Line + 1, start.Column + 1, end.Line + 1, end.Column + 1), contexts);
+ return new ExpressionResult (editor.GetTextBetween (startOffset, endOffset), new DomRegion (start.Line, start.Column, end.Line, end.Column), contexts);
}
/*
public string RemoveLastPart (string expression)
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/ResolveVisitor.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/ResolveVisitor.cs
index d0bdac88d8..74d4572298 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/ResolveVisitor.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/ResolveVisitor.cs
@@ -281,7 +281,7 @@ namespace MonoDevelop.CSharp.Resolver
foreach (Expression expr in initializer.CreateExpressions) {
var oldPos = resolver.ResolvePosition;
if (!expr.StartLocation.IsEmpty)
- resolver.resolvePosition = new DomLocation (expr.StartLocation.Line + resolver.CallingMember.Location.Line - 1, expr.StartLocation.Column - 1);
+ resolver.resolvePosition = new DomLocation (expr.StartLocation.Line + resolver.CallingMember.Location.Line, expr.StartLocation.Column);
DomProperty newProperty = new DomProperty (GetAnonymousTypeFieldName (expr), MonoDevelop.Projects.Dom.Modifiers.Public, DomLocation.Empty, DomRegion.Empty, ResolveType (expr));
newProperty.DeclaringType = result;
result.Add (newProperty);
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/TextEditorResolverProvider.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/TextEditorResolverProvider.cs
index bdd3eeed49..9807bafe2d 100644
--- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/TextEditorResolverProvider.cs
+++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Resolver/TextEditorResolverProvider.cs
@@ -66,7 +66,7 @@ namespace MonoDevelop.CSharp.Resolver
while (wordEnd < data.Length - 1 && Char.IsWhiteSpace (data.GetCharAt (wordEnd)))
wordEnd++;
-
+ /* is checked at the end.
int saveEnd = wordEnd;
if (wordEnd < data.Length && data.GetCharAt (wordEnd) == '<') {
int matchingBracket = data.Document.GetMatchingBracketOffset (wordEnd);
@@ -85,19 +85,19 @@ namespace MonoDevelop.CSharp.Resolver
}
}
if (!wasMethodCall)
- wordEnd = saveEnd;
+ wordEnd = saveEnd;*/
ExpressionResult expressionResult = expressionFinder.FindExpression (data, wordEnd);
if (expressionResult == null)
return null;
-
+
ResolveResult resolveResult;
DocumentLocation loc = data.Document.OffsetToLocation (offset);
string savedExpression = null;
// special handling for 'var' "keyword"
if (expressionResult.ExpressionContext == ExpressionContext.IdentifierExpected && expressionResult.Expression != null && expressionResult.Expression.Trim () == "var") {
- int endOffset = data.Document.LocationToOffset (expressionResult.Region.End.Line - 1, expressionResult.Region.End.Column - 1);
+ int endOffset = data.Document.LocationToOffset (expressionResult.Region.End.Line, expressionResult.Region.End.Column);
StringBuilder identifer = new StringBuilder ();
for (int i = endOffset; i >= 0 && i < data.Document.Length; i++) {
char ch = data.Document.GetCharAt (i);
@@ -114,7 +114,7 @@ namespace MonoDevelop.CSharp.Resolver
}
if (identifer.Length > 0) {
expressionResult.Expression = identifer.ToString ();
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
if (resolveResult != null) {
resolveResult = new MemberResolveResult (dom.GetType (resolveResult.ResolvedType));
resolveResult.ResolvedExpression = expressionResult;
@@ -128,16 +128,16 @@ namespace MonoDevelop.CSharp.Resolver
expressionResult.Expression += "Attribute";
expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
}
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
if (savedExpression != null && resolveResult == null) {
expressionResult.Expression = savedExpression;
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
}
// Search for possible generic parameters.
// if (this.resolveResult == null || this.resolveResult.ResolvedType == null || String.IsNullOrEmpty (this.resolveResult.ResolvedType.Name)) {
if (!expressionResult.Region.IsEmpty) {
- int j = data.Document.LocationToOffset (expressionResult.Region.End.Line - 1, expressionResult.Region.End.Column - 1);
+ int j = data.Document.LocationToOffset (expressionResult.Region.End.Line, expressionResult.Region.End.Column);
int bracket = 0;
for (int i = j; i >= 0 && i < data.Document.Length; i++) {
char ch = data.Document.GetCharAt (i);
@@ -150,7 +150,7 @@ namespace MonoDevelop.CSharp.Resolver
if (bracket == 0) {
expressionResult.Expression += data.Document.GetTextBetween (j, i + 1);
expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
break;
}
} else {
@@ -176,8 +176,8 @@ namespace MonoDevelop.CSharp.Resolver
wordEnd = matchingBracket;
}
//Console.WriteLine (expressionFinder.FindFullExpression (txt, wordEnd));
- ResolveResult possibleResult = resolver.Resolve (expressionFinder.FindFullExpression (data, wordEnd), new DomLocation (loc.Line + 1, loc.Column + 1)) ?? resolveResult;
- //Console.WriteLine ("possi:" + resolver.Resolve (expressionFinder.FindFullExpression (txt, wordEnd), new DomLocation (loc.Line + 1, loc.Column + 1)));
+ ResolveResult possibleResult = resolver.Resolve (expressionFinder.FindFullExpression (data, wordEnd), new DomLocation (loc.Line, loc.Column)) ?? resolveResult;
+ //Console.WriteLine ("possi:" + resolver.Resolve (expressionFinder.FindFullExpression (txt, wordEnd), new DomLocation (loc.Line, loc.Column)));
if (possibleResult is MethodResolveResult)
resolveResult = possibleResult;
}
@@ -214,14 +214,16 @@ namespace MonoDevelop.CSharp.Resolver
expressionResult.Expression += "Attribute";
expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
}
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
if (savedExpression != null && resolveResult == null) {
expressionResult.Expression = savedExpression;
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column));
}
+ if (expressionResult.Region.End.IsEmpty)
+ return resolveResult;
// Search for possible generic parameters.
// if (this.resolveResult == null || this.resolveResult.ResolvedType == null || String.IsNullOrEmpty (this.resolveResult.ResolvedType.Name)) {
- int j = data.Document.LocationToOffset (expressionResult.Region.End.Line - 1, expressionResult.Region.End.Column - 1);
+ int j = data.Document.LocationToOffset (expressionResult.Region.End.Line, expressionResult.Region.End.Column);
int bracket = 0;
for (int i = j; i >= 0 && i < data.Document.Length; i++) {
char ch = data.Document.GetCharAt (i);
@@ -234,7 +236,7 @@ namespace MonoDevelop.CSharp.Resolver
if (bracket == 0) {
expressionResult.Expression += data.Document.GetTextBetween (j, i + 1);
expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
- resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
+ resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line, loc.Column)) ?? resolveResult;
break;
}
} else {
@@ -247,7 +249,7 @@ namespace MonoDevelop.CSharp.Resolver
// To resolve method overloads the full expression must be parsed.
// ex.: Overload (1)/ Overload("one") - parsing "Overload" gives just a MethodResolveResult
if (resolveResult is MethodResolveResult)
- resolveResult = resolver.Resolve (expressionFinder.FindFullExpression (data, wordEnd), new DomLocation (loc.Line + 1, loc.Column + 1)) ?? resolveResult;
+ resolveResult = resolver.Resolve (expressionFinder.FindFullExpression (data, wordEnd), new DomLocation (loc.Line, loc.Column)) ?? resolveResult;
return resolveResult;
}
diff --git a/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs
index 54f054b829..d20285d0bd 100644
--- a/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs
+++ b/main/src/addins/MonoDevelop.AnalysisCore/Gui/ResultMarker.cs
@@ -34,8 +34,8 @@ namespace MonoDevelop.AnalysisCore.Gui
public ResultMarker (Result result) : base (
GetColor (result),
- IsOneLine (result)? (result.Region.Start.Column - 1) : -1,
- IsOneLine (result)? (result.Region.End.Column - 1) : -1)
+ IsOneLine (result)? (result.Region.Start.Column) : 0,
+ IsOneLine (result)? (result.Region.End.Column) : 0)
{
this.result = result;
}
@@ -48,9 +48,9 @@ namespace MonoDevelop.AnalysisCore.Gui
public Result Result { get { return result; } }
//utility for debugging
- public int Line { get { return result.Region.Start.Line - 1; } }
- public int ColStart { get { return IsOneLine (result)? (result.Region.Start.Column - 1) : -1; } }
- public int ColEnd { get { return IsOneLine (result)? (result.Region.End.Column - 1) : -1; } }
+ public int Line { get { return result.Region.Start.Line; } }
+ public int ColStart { get { return IsOneLine (result)? (result.Region.Start.Column) : 0; } }
+ public int ColEnd { get { return IsOneLine (result)? (result.Region.End.Column) : 0; } }
public string Message { get { return result.Message; } }
static string GetColor (Result result)
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
index c87cb27637..d9261c45c9 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
@@ -841,7 +841,7 @@ namespace MonoDevelop.Debugger
if (doc != null) {
ITextEditorResolver textEditorResolver = doc.GetContent <ITextEditorResolver> ();
if (textEditorResolver != null) {
- ResolveResult rr = textEditorResolver.GetLanguageItem (doc.Editor.Document.LocationToOffset (location.Line - 1, 0), identifier);
+ ResolveResult rr = textEditorResolver.GetLanguageItem (doc.Editor.Document.LocationToOffset (location.Line, 1), identifier);
NamespaceResolveResult ns = rr as NamespaceResolveResult;
if (ns != null)
return ns.Namespace;
diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ClassOutlineTextEditorExtension.cs b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ClassOutlineTextEditorExtension.cs
index 5056488ebf..cb3c60fe8d 100644
--- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ClassOutlineTextEditorExtension.cs
+++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/ClassOutlineTextEditorExtension.cs
@@ -112,9 +112,8 @@ namespace MonoDevelop.DesignerSupport
line = ((IMember)o).BodyRegion.Start.Line;
col = ((IMember)o).BodyRegion.Start.Column;
}
- if (line > -1) {
- Editor.SetCaretTo (line - 1, Math.Max (1, col) - 1);
- }
+ if (line > -1)
+ Editor.SetCaretTo (line, Math.Max (1, col));
};
this.lastCU = Document.ParsedDocument;
@@ -277,7 +276,7 @@ namespace MonoDevelop.DesignerSupport
static bool OuterEndsAfterInner (DomRegion outer, DomRegion inner)
{
- return ((outer.End.Line > 0 && outer.End.Line > inner.End.Line) || (outer.End.Line == inner.End.Line && outer.End.Column > inner.End.Column));
+ return ((outer.End.Line > 1 && outer.End.Line > inner.End.Line) || (outer.End.Line == inner.End.Line && outer.End.Column > inner.End.Column));
}
}
}
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs
index e85be0c574..6cf8708fa0 100644
--- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs
+++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs
@@ -101,7 +101,7 @@ namespace MonoDevelop.DocFood
static bool NeedsDocumentation (TextEditorData data, IMember member)
{
- int lineNr = member.Location.Line - 1;
+ int lineNr = member.Location.Line;
LineSegment line;
do {
line = data.Document.GetLine (lineNr--);
@@ -114,7 +114,7 @@ namespace MonoDevelop.DocFood
static string GetIndent (TextEditorData data, IMember member, out int offset)
{
- LineSegment line = data.Document.GetLine (member.Location.Line - 1);
+ LineSegment line = data.Document.GetLine (member.Location.Line);
offset = line.Offset;
return data.Document.GetLineIndent (line);
}
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs
index f5cac4392f..bd8cf40af1 100644
--- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs
+++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs
@@ -97,7 +97,7 @@ namespace MonoDevelop.DocFood
return null;
IMember result = null;
foreach (IMember member in type.Members) {
- if (member.Location > new DomLocation (textEditorData.Caret.Line + 1, textEditorData.Caret.Column + 1) && (result == null || member.Location < result.Location))
+ if (member.Location > new DomLocation (textEditorData.Caret.Line, textEditorData.Caret.Column) && (result == null || member.Location < result.Location))
result = member;
}
return result;
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs
index cffaa20afa..d19b2cb159 100644
--- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs
+++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs
@@ -377,9 +377,9 @@ namespace MonoDevelop.DocFood
void Init (IMember member)
{
FillDocumentation (GetBaseDocumentation (member));
- if (provider != null && !member.Location.IsEmpty && member.BodyRegion.End.Line > 0) {
- LineSegment start = data.Document.GetLine (member.Location.Line - 1);
- LineSegment end = data.Document.GetLine (member.BodyRegion.End.Line - 1);
+ if (provider != null && !member.Location.IsEmpty && member.BodyRegion.End.Line > 1) {
+ LineSegment start = data.Document.GetLine (member.Location.Line);
+ LineSegment end = data.Document.GetLine (member.BodyRegion.End.Line);
if (start != null && end != null) {
var result = provider.ParseFile ("class A {" + data.Document.GetTextAt (start.Offset, end.EndOffset - start.Offset) + "}");
result.AcceptVisitor (visitor, null);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/CodeGenerationOptions.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/CodeGenerationOptions.cs
index 3ced249a46..b3be441430 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/CodeGenerationOptions.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/CodeGenerationOptions.cs
@@ -72,7 +72,7 @@ namespace MonoDevelop.CodeGeneration
public ICSharpCode.NRefactory.Ast.TypeReference ShortenTypeName (ICSharpCode.NRefactory.Ast.TypeReference typeReference)
{
- return Document.CompilationUnit.ShortenTypeName (typeReference.ConvertToReturnType (), Document.Editor.Caret.Line + 1, Document.Editor.Caret.Column + 1).ConvertToTypeReference ();
+ return Document.CompilationUnit.ShortenTypeName (typeReference.ConvertToReturnType (), Document.Editor.Caret.Line, Document.Editor.Caret.Column).ConvertToTypeReference ();
}
public IResolver GetResolver ()
@@ -90,8 +90,8 @@ namespace MonoDevelop.CodeGeneration
Document = document,
};
if (document.ParsedDocument != null && document.ParsedDocument.CompilationUnit != null) {
- options.EnclosingType = document.ParsedDocument.CompilationUnit.GetTypeAt (document.Editor.Caret.Line + 1, document.Editor.Caret.Column + 1);
- options.EnclosingMember = document.ParsedDocument.CompilationUnit.GetMemberAt (document.Editor.Caret.Line + 1, document.Editor.Caret.Column + 1);
+ options.EnclosingType = document.ParsedDocument.CompilationUnit.GetTypeAt (document.Editor.Caret.Line, document.Editor.Caret.Column);
+ options.EnclosingMember = document.ParsedDocument.CompilationUnit.GetMemberAt (document.Editor.Caret.Line, document.Editor.Caret.Column);
}
return options;
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/WriteLineGenerator.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/WriteLineGenerator.cs
index 041bbcb1aa..3c5d4093b2 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/WriteLineGenerator.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeGeneration/WriteLineGenerator.cs
@@ -85,7 +85,7 @@ namespace MonoDevelop.CodeGeneration
// add local variables
LookupTableVisitor visitor = new LookupTableVisitor (ICSharpCode.NRefactory.SupportedLanguage.CSharp);
- Location location = new Location (Options.Document.Editor.Caret.Line + 1, Options.Document.Editor.Caret.Column + 1);
+ Location location = new Location (Options.Document.Editor.Caret.Line, Options.Document.Editor.Caret.Column);
INRefactoryASTProvider provider = Options.GetASTProvider ();
var result = provider.ParseFile (Options.Document.Editor.Text);
result.AcceptVisitor (visitor, null);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/CreateBackingStore.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/CreateBackingStore.cs
index e181be1968..74b3cdc63d 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/CreateBackingStore.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/CreateBackingStore.cs
@@ -51,9 +51,9 @@ namespace MonoDevelop.Refactoring.ConvertPropery
if (property == null || resolveResult.CallingMember == null || resolveResult.CallingMember.FullName != property.FullName || !property.HasGet || property.DeclaringType == null)
return false;
TextEditorData data = options.GetTextEditorData ();
- if (property.HasGet && data.Document.GetCharAt (data.Document.LocationToOffset (property.GetRegion.End.Line - 1, property.GetRegion.End.Column - 2)) != ';')
+ if (property.HasGet && data.Document.GetCharAt (data.Document.LocationToOffset (property.GetRegion.End.Line, property.GetRegion.End.Column - 1)) != ';')
return false;
- if (property.HasSet && data.Document.GetCharAt (data.Document.LocationToOffset (property.SetRegion.End.Line - 1, property.SetRegion.End.Column - 2)) != ';')
+ if (property.HasSet && data.Document.GetCharAt (data.Document.LocationToOffset (property.SetRegion.End.Line, property.SetRegion.End.Column - 1)) != ';')
return false;
return true;
}
@@ -109,7 +109,7 @@ namespace MonoDevelop.Refactoring.ConvertPropery
backingStore.TypeReference = options.Document.CompilationUnit.ShortenTypeName (property.ReturnType, property.Location).ConvertToTypeReference ();
backingStore.Fields.Add (new VariableDeclaration (backingStoreName));
DocumentLocation location = property.Location.ToDocumentLocation (data.Document);
- location.Column = 0;
+ location.Column = 1;
refactoringStartOffset = data.Document.LocationToOffset (location);
result.Add (new TextReplaceChange () {
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/RemoveBackingStore.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/RemoveBackingStore.cs
index f4da9a087c..1fd3d9a4f8 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/RemoveBackingStore.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ConvertPropery/RemoveBackingStore.cs
@@ -53,9 +53,9 @@ namespace MonoDevelop.Refactoring.ConvertPropery
return false;
TextEditorData data = options.GetTextEditorData ();
- if (property.HasGet && data.Document.GetCharAt (data.Document.LocationToOffset (property.GetRegion.End.Line - 1, property.GetRegion.End.Column - 2)) == ';')
+ if (property.HasGet && data.Document.GetCharAt (data.Document.LocationToOffset (property.GetRegion.End.Line, property.GetRegion.End.Column - 1)) == ';')
return false;
- if (property.HasSet && data.Document.GetCharAt (data.Document.LocationToOffset (property.SetRegion.End.Line - 1, property.SetRegion.End.Column - 2)) == ';')
+ if (property.HasSet && data.Document.GetCharAt (data.Document.LocationToOffset (property.SetRegion.End.Line, property.SetRegion.End.Column - 1)) == ';')
return false;
INRefactoryASTProvider astProvider = options.GetASTProvider ();
string backingStoreName = RetrieveBackingStore (options, astProvider, property);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateClass/CreateClassCodeGenerator.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateClass/CreateClassCodeGenerator.cs
index 37a36bbe46..7879794cdc 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateClass/CreateClassCodeGenerator.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateClass/CreateClassCodeGenerator.cs
@@ -74,7 +74,7 @@ namespace MonoDevelop.Refactoring.CreateClass
return null;
string expression = options.ResolveResult.ResolvedExpression.Expression;
if (!expression.Contains ("(")) {
- int startPos = data.Document.LocationToOffset (options.ResolveResult.ResolvedExpression.Region.Start.Line - 1, options.ResolveResult.ResolvedExpression.Region.Start.Column - 1);
+ int startPos = data.Document.LocationToOffset (options.ResolveResult.ResolvedExpression.Region.Start.Line, options.ResolveResult.ResolvedExpression.Region.Start.Column);
if (startPos < 0)
return null;
for (int pos = startPos; pos < data.Document.Length; pos++) {
@@ -89,7 +89,7 @@ namespace MonoDevelop.Refactoring.CreateClass
}
}
if (!expression.StartsWith ("new ")) {
- int startPos = data.Document.LocationToOffset (options.ResolveResult.ResolvedExpression.Region.Start.Line - 1, options.ResolveResult.ResolvedExpression.Region.Start.Column - 1);
+ int startPos = data.Document.LocationToOffset (options.ResolveResult.ResolvedExpression.Region.Start.Line, options.ResolveResult.ResolvedExpression.Region.Start.Column);
if (startPos < 0)
return null;
for (int pos = startPos; pos >= 0; pos--) {
@@ -161,7 +161,7 @@ namespace MonoDevelop.Refactoring.CreateClass
constructor.Parameters.Add (pde);
}
ICSharpCode.NRefactory.Ast.INode node = newType;
- IType curType = options.Document.CompilationUnit.GetTypeAt (options.Document.Editor.Caret.Line - 1, options.Document.Editor.Caret.Column - 1);
+ IType curType = options.Document.CompilationUnit.GetTypeAt (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column);
if (curType != null && !string.IsNullOrEmpty (curType.Namespace)) {
NamespaceDeclaration namespaceDeclaration = new NamespaceDeclaration (curType.Namespace);
namespaceDeclaration.Children.Add (newType);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateMethod/CreateMethodCodeGenerator.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateMethod/CreateMethodCodeGenerator.cs
index 0f1e8e83f2..e3275b9826 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateMethod/CreateMethodCodeGenerator.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.CreateMethod/CreateMethodCodeGenerator.cs
@@ -60,7 +60,7 @@ namespace MonoDevelop.Refactoring.CreateMethod
return false;
returnType = DomReturnType.Void;
modifiers = ICSharpCode.NRefactory.Ast.Modifiers.None;
- resolvePosition = new DomLocation (options.Document.Editor.Caret.Line + 1, options.Document.Editor.Caret.Column + 1);
+ resolvePosition = new DomLocation (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column);
ResolveResult resolveResult = resolver.Resolve (new ExpressionResult (provider.OutputNode (options.Dom, invoke)), resolvePosition);
if (resolveResult is MethodResolveResult) {
@@ -96,7 +96,7 @@ namespace MonoDevelop.Refactoring.CreateMethod
return null;
string expression = options.ResolveResult.ResolvedExpression.Expression;
if (!expression.Contains ("(")) {
- int startPos = data.Document.LocationToOffset (options.ResolveResult.ResolvedExpression.Region.Start.Line - 1, options.ResolveResult.ResolvedExpression.Region.Start.Column - 1);
+ int startPos = data.Document.LocationToOffset (options.ResolveResult.ResolvedExpression.Region.Start.Line, options.ResolveResult.ResolvedExpression.Region.Start.Column);
if (startPos < 0)
return null;
bool gotWs = false;
@@ -167,7 +167,7 @@ namespace MonoDevelop.Refactoring.CreateMethod
if (data == null)
throw new InvalidOperationException ("Can't open file:" + modifiers);
try {
- indent = data.Document.GetLine (type.Location.Line - 1).GetIndentation (data.Document) ?? "";
+ indent = data.Document.GetLine (type.Location.Line).GetIndentation (data.Document) ?? "";
} catch (Exception) {
indent = "";
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.DeclareLocal/DeclareLocalCodeGenerator.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.DeclareLocal/DeclareLocalCodeGenerator.cs
index 04e3165d54..79ef5b3d63 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.DeclareLocal/DeclareLocalCodeGenerator.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.DeclareLocal/DeclareLocalCodeGenerator.cs
@@ -85,7 +85,7 @@ namespace MonoDevelop.Refactoring.DeclareLocal
if (expression == null || (block != null && block.Children[0] is LocalVariableDeclaration))
return false;
- resolveResult = resolver.Resolve (new ExpressionResult (line), new DomLocation (options.Document.Editor.Caret.Line - 1, options.Document.Editor.Caret.Column - 1));
+ resolveResult = resolver.Resolve (new ExpressionResult (line), new DomLocation (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column));
return resolveResult.ResolvedType != null && !string.IsNullOrEmpty (resolveResult.ResolvedType.FullName) && resolveResult.ResolvedType.FullName != DomReturnType.Void.FullName;
}
@@ -189,16 +189,16 @@ namespace MonoDevelop.Refactoring.DeclareLocal
varDecl.Variables.Add (new VariableDeclaration (varName, provider.ParseExpression (data.SelectedText)));
GetContainingEmbeddedStatementVisitor blockVisitor = new GetContainingEmbeddedStatementVisitor ();
- blockVisitor.LookupLocation = new Location (data.Caret.Column + 1, data.Caret.Line + 1);
-
+ blockVisitor.LookupLocation = new Location (data.Caret.Column, data.Caret.Line );
+
unit.AcceptVisitor (blockVisitor, null);
StatementWithEmbeddedStatement containing = blockVisitor.ContainingStatement as StatementWithEmbeddedStatement;
if (containing != null && !(containing.EmbeddedStatement is BlockStatement)) {
- insert.Offset = data.Document.LocationToOffset (containing.StartLocation.Line - 1, containing.StartLocation.Column - 1);
+ insert.Offset = data.Document.LocationToOffset (containing.StartLocation.Line, containing.StartLocation.Column);
lineSegment = data.Document.GetLineByOffset (insert.Offset);
- insert.RemovedChars = data.Document.LocationToOffset (containing.EndLocation.Line - 1, containing.EndLocation.Column - 1) - insert.Offset;
+ insert.RemovedChars = data.Document.LocationToOffset (containing.EndLocation.Line, containing.EndLocation.Column) - insert.Offset;
BlockStatement insertedBlock = new BlockStatement ();
insertedBlock.AddChild (varDecl);
insertedBlock.AddChild (containing.EmbeddedStatement);
@@ -215,9 +215,9 @@ namespace MonoDevelop.Refactoring.DeclareLocal
} else if (blockVisitor.ContainingStatement is IfElseStatement) {
IfElseStatement ifElse = blockVisitor.ContainingStatement as IfElseStatement;
- insert.Offset = data.Document.LocationToOffset (blockVisitor.ContainingStatement.StartLocation.Line - 1, blockVisitor.ContainingStatement.StartLocation.Column - 1);
+ insert.Offset = data.Document.LocationToOffset (blockVisitor.ContainingStatement.StartLocation.Line, blockVisitor.ContainingStatement.StartLocation.Column);
lineSegment = data.Document.GetLineByOffset (insert.Offset);
- insert.RemovedChars = data.Document.LocationToOffset (blockVisitor.ContainingStatement.EndLocation.Line - 1, blockVisitor.ContainingStatement.EndLocation.Column - 1) - insert.Offset;
+ insert.RemovedChars = data.Document.LocationToOffset (blockVisitor.ContainingStatement.EndLocation.Line, blockVisitor.ContainingStatement.EndLocation.Column) - insert.Offset;
BlockStatement insertedBlock = new BlockStatement ();
insertedBlock.AddChild (varDecl);
if (blockVisitor.ContainsLocation (ifElse.TrueStatement[0])) {
@@ -268,7 +268,7 @@ namespace MonoDevelop.Refactoring.DeclareLocal
if (expression == null)
return result;
- resolveResult = resolver.Resolve (new ExpressionResult (line), new DomLocation (options.Document.Editor.Caret.Line - 1, options.Document.Editor.Caret.Column - 1));
+ resolveResult = resolver.Resolve (new ExpressionResult (line), new DomLocation (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column));
if (resolveResult.ResolvedType != null && !string.IsNullOrEmpty (resolveResult.ResolvedType.FullName)) {
TextReplaceChange insert = new TextReplaceChange ();
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/ExtractMethodRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/ExtractMethodRefactoring.cs
index 9efe252fb3..9fa90522a7 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/ExtractMethodRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/ExtractMethodRefactoring.cs
@@ -65,7 +65,7 @@ namespace MonoDevelop.Refactoring.ExtractMethod
if (buffer.IsSomethingSelected) {
ParsedDocument doc = options.ParseDocument ();
if (doc != null && doc.CompilationUnit != null) {
- if (doc.CompilationUnit.GetMemberAt (buffer.Caret.Line + 1, buffer.Caret.Column + 1) == null)
+ if (doc.CompilationUnit.GetMemberAt (buffer.Caret.Line, buffer.Caret.Column) == null)
return false;
return true;
}
@@ -101,13 +101,13 @@ namespace MonoDevelop.Refactoring.ExtractMethod
if (doc == null || doc.CompilationUnit == null)
return null;
- IMember member = doc.CompilationUnit.GetMemberAt (buffer.Caret.Line + 1, buffer.Caret.Column + 1);
+ IMember member = doc.CompilationUnit.GetMemberAt (buffer.Caret.Line, buffer.Caret.Column);
if (member == null)
return null;
ExtractMethodParameters param = new ExtractMethodParameters () {
DeclaringMember = member,
- Location = new DomLocation (buffer.Caret.Line + 1, buffer.Caret.Column + 1)
+ Location = new DomLocation (buffer.Caret.Line, buffer.Caret.Column)
};
Analyze (options, param, true);
return param;
@@ -434,7 +434,7 @@ namespace MonoDevelop.Refactoring.ExtractMethod
ExtractMethodAstTransformer transformer = new ExtractMethodAstTransformer (param.VariablesToGenerate);
node.AcceptVisitor (transformer, null);
if (!param.OneChangedVariable && node is Expression) {
- ResolveResult resolveResult = resolver.Resolve (new ExpressionResult ("(" + provider.OutputNode (options.Dom, node) + ")"), new DomLocation (options.Document.Editor.Caret.Line + 1, options.Document.Editor.Caret.Column + 1));
+ ResolveResult resolveResult = resolver.Resolve (new ExpressionResult ("(" + provider.OutputNode (options.Dom, node) + ")"), new DomLocation (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column));
if (resolveResult.ResolvedType != null)
returnType = options.ShortenTypeName (resolveResult.ResolvedType).ConvertToTypeReference ();
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/VariableLookupVisitor.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/VariableLookupVisitor.cs
index 3f74edc421..a9f13e0033 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/VariableLookupVisitor.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ExtractMethod/VariableLookupVisitor.cs
@@ -151,12 +151,12 @@ namespace MonoDevelop.Refactoring.ExtractMethod
public override object VisitLocalVariableDeclaration (LocalVariableDeclaration localVariableDeclaration, object data)
{
- if (!CutRegion.Contains (localVariableDeclaration.StartLocation.Line - 1, localVariableDeclaration.StartLocation.Column -1)) {
+ if (!CutRegion.Contains (localVariableDeclaration.StartLocation.Line, localVariableDeclaration.StartLocation.Column)) {
foreach (VariableDeclaration varDecl in localVariableDeclaration.Variables) {
variables[varDecl.Name] = new VariableDescriptor (varDecl.Name) {
IsDefined = true,
ReturnType = ConvertTypeReference (localVariableDeclaration.TypeReference),
- Location = new DocumentLocation (MemberLocation.Line + localVariableDeclaration.StartLocation.Line - 1, localVariableDeclaration.StartLocation.Column - 1)
+ Location = new DocumentLocation (MemberLocation.Line + localVariableDeclaration.StartLocation.Line, localVariableDeclaration.StartLocation.Column)
};
}
}
@@ -181,7 +181,7 @@ namespace MonoDevelop.Refactoring.ExtractMethod
if (!result.StaticResolve && !variables.ContainsKey (identifierExpression.Identifier)) {
variables[identifierExpression.Identifier] = new VariableDescriptor (identifierExpression.Identifier) {
InitialValueUsed = !valueGetsChanged,
- Location = new DocumentLocation (MemberLocation.Line + identifierExpression.StartLocation.Line - 1, identifierExpression.StartLocation.Column - 1)
+ Location = new DocumentLocation (MemberLocation.Line + identifierExpression.StartLocation.Line, identifierExpression.StartLocation.Column)
};
variables[identifierExpression.Identifier].ReturnType = result.ResolvedType;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementAbstractMembers.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementAbstractMembers.cs
index 03e334b0ad..6b5fb88804 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementAbstractMembers.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementAbstractMembers.cs
@@ -57,7 +57,7 @@ namespace MonoDevelop.Refactoring.ImplementInterface
{
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
IType interfaceType = options.Dom.GetType (options.ResolveResult.ResolvedType);
- IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
+ IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
options.Document.Editor.Document.BeginAtomicUndo ();
CodeRefactorer refactorer = IdeApp.Workspace.GetCodeRefactorer (IdeApp.ProjectOperations.CurrentSelectedSolution);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementExplicit.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementExplicit.cs
index 7ed869da04..0c9f8c8073 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementExplicit.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementExplicit.cs
@@ -50,7 +50,7 @@ namespace MonoDevelop.Refactoring.ImplementInterface
if (type == null || type.ClassType != MonoDevelop.Projects.Dom.ClassType.Interface)
return false;
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
- IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
+ IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
return declaringType != null && options.ResolveResult.ResolvedExpression.IsInInheritableTypeContext;
}
@@ -58,7 +58,7 @@ namespace MonoDevelop.Refactoring.ImplementInterface
{
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
IType interfaceType = options.Dom.GetType (options.ResolveResult.ResolvedType);
- IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
+ IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
var editor = options.GetTextEditorData ().Parent;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementImplicit.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementImplicit.cs
index 031b1ec855..d257bb1fc9 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementImplicit.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.ImplementInterface/ImplementImplicit.cs
@@ -53,7 +53,7 @@ namespace MonoDevelop.Refactoring.ImplementInterface
if (!CodeGenerator.HasGenerator (options.GetTextEditorData ().Document.MimeType))
return false;
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
- IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
+ IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
return declaringType != null && options.ResolveResult.ResolvedExpression.IsInInheritableTypeContext;
}
@@ -61,7 +61,7 @@ namespace MonoDevelop.Refactoring.ImplementInterface
{
DocumentLocation location = options.GetTextEditorData ().Caret.Location;
IType interfaceType = options.Dom.GetType (options.ResolveResult.ResolvedType);
- IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line + 1, location.Column + 1);
+ IType declaringType = options.Document.CompilationUnit.GetTypeAt (location.Line, location.Column);
var editor = options.GetTextEditorData ().Parent;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntegrateTemporaryVariable/IntegrateTemporaryVariableRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntegrateTemporaryVariable/IntegrateTemporaryVariableRefactoring.cs
index dd47cc9560..8b03f1a994 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntegrateTemporaryVariable/IntegrateTemporaryVariableRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntegrateTemporaryVariable/IntegrateTemporaryVariableRefactoring.cs
@@ -60,8 +60,8 @@ namespace MonoDevelop.Refactoring.IntegrateTemporaryVariable
IMember member = ((LocalVariable) options.SelectedItem).DeclaringMember;
if (member == null)
return null;
- int start = options.Document.Editor.Document.LocationToOffset (member.BodyRegion.Start.Line - 1, member.BodyRegion.Start.Column - 1);
- int end = options.Document.Editor.Document.LocationToOffset (member.BodyRegion.End.Line - 1, member.BodyRegion.End.Column - 1);
+ int start = options.Document.Editor.Document.LocationToOffset (member.BodyRegion.Start.Line, member.BodyRegion.Start.Column);
+ int end = options.Document.Editor.Document.LocationToOffset (member.BodyRegion.End.Line, member.BodyRegion.End.Column);
string memberBody = options.Document.Editor.GetTextBetween (start, end);
INRefactoryASTProvider provider = options.GetASTProvider ();
if (provider == null) {
@@ -147,7 +147,7 @@ namespace MonoDevelop.Refactoring.IntegrateTemporaryVariable
change.Description = string.Format (GettextCatalog.GetString ("Substitute variable {0} with the Initializeexpression"), options.GetName ());
change.FileName = options.Options.Document.FileName;
- change.Offset = options.Options.Document.Editor.Document.LocationToOffset (toReplace.StartLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line - 1, toReplace.StartLocation.Column - 1);
+ change.Offset = options.Options.Document.Editor.Document.LocationToOffset (toReplace.StartLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line, toReplace.StartLocation.Column);
change.RemovedChars = options.GetName ().Length;
INRefactoryASTProvider provider = options.Options.GetASTProvider ();
@@ -170,8 +170,8 @@ namespace MonoDevelop.Refactoring.IntegrateTemporaryVariable
change.Description = string.Format (GettextCatalog.GetString ("Deleting local variable declaration {0}"), options.GetName ());
change.FileName = options.Options.Document.FileName;
- change.Offset = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.StartLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line - 1, localVariableDeclaration.StartLocation.Column - 1);
- int end = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.EndLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line - 1, localVariableDeclaration.EndLocation.Column - 1);
+ change.Offset = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.StartLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line, localVariableDeclaration.StartLocation.Column);
+ int end = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.EndLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line, localVariableDeclaration.EndLocation.Column);
change.RemovedChars = end - change.Offset;
change.InsertedText = "";
@@ -181,8 +181,8 @@ namespace MonoDevelop.Refactoring.IntegrateTemporaryVariable
change.Description = string.Format (GettextCatalog.GetString ("Deleting local variable declaration {0}"), options.GetName ());
change.FileName = options.Options.Document.FileName;
- change.Offset = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.StartLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line - 1, localVariableDeclaration.StartLocation.Column - 1);
- int end = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.EndLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line - 1, localVariableDeclaration.EndLocation.Column - 1);
+ change.Offset = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.StartLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line, localVariableDeclaration.StartLocation.Column);
+ int end = options.Options.Document.Editor.Document.LocationToOffset (localVariableDeclaration.EndLocation.Line + ((LocalVariable)options.Options.SelectedItem).DeclaringMember.BodyRegion.Start.Line, localVariableDeclaration.EndLocation.Column);
change.RemovedChars = end - change.Offset;
localVariableDeclaration.Variables.Remove (localVariableDeclaration.GetVariableDeclaration (options.GetName ()));
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceConstant/IntroduceConstantRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceConstant/IntroduceConstantRefactoring.cs
index 6256b0ed08..40ddf77b5c 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceConstant/IntroduceConstantRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceConstant/IntroduceConstantRefactoring.cs
@@ -160,8 +160,8 @@ namespace MonoDevelop.Refactoring.IntroduceConstant
resolveResult = resolver.Resolve (new ExpressionResult (SearchNumber (data, out start, out end)), DomLocation.Empty);
}
} else {
- start = data.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.Start.Line - 1, resolveResult.ResolvedExpression.Region.Start.Column - 1);
- end = data.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.End.Line - 1, resolveResult.ResolvedExpression.Region.End.Column - 1);
+ start = data.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.Start.Line, resolveResult.ResolvedExpression.Region.Start.Column);
+ end = data.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.End.Line, resolveResult.ResolvedExpression.Region.End.Column);
}
if (start == 0 && end == 0)
return result;
@@ -179,7 +179,7 @@ namespace MonoDevelop.Refactoring.IntroduceConstant
TextReplaceChange insertConstant = new TextReplaceChange ();
insertConstant.FileName = options.Document.FileName;
insertConstant.Description = string.Format (GettextCatalog.GetString ("Generate constant '{0}'"), param.Name);
- insertConstant.Offset = data.Document.LocationToOffset (curMember.Location.Line - 1, 0);
+ insertConstant.Offset = data.Document.LocationToOffset (curMember.Location.Line, 1);
insertConstant.InsertedText = provider.OutputNode (options.Dom, fieldDeclaration, options.GetIndent (curMember)) + Environment.NewLine;
result.Add (insertConstant);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceFormatItem/IntroduceFormatItemRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceFormatItem/IntroduceFormatItemRefactoring.cs
index 3f79661b09..f81a948703 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceFormatItem/IntroduceFormatItemRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.IntroduceFormatItem/IntroduceFormatItemRefactoring.cs
@@ -106,8 +106,8 @@ namespace MonoDevelop.Refactoring.IntroduceFormat
expr.StringValue = '"' + str + '"';
possibleFormatCall.Arguments.Add (new PrimitiveExpression (data.Document.GetTextAt (data.SelectionRange)));
formatCall = possibleFormatCall;
- start = data.Document.LocationToOffset (expressionResult.Region.Start.Line - 1, expressionResult.Region.Start.Column - 1);
- end = data.Document.LocationToOffset (expressionResult.Region.End.Line - 1, expressionResult.Region.End.Column - 1) - 1;
+ start = data.Document.LocationToOffset (expressionResult.Region.Start.Line, expressionResult.Region.Start.Column);
+ end = data.Document.LocationToOffset (expressionResult.Region.End.Line, expressionResult.Region.End.Column) - 1;
}
}
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.MoveTypeToFile/MoveTypeToFileRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.MoveTypeToFile/MoveTypeToFileRefactoring.cs
index aa0cb9be77..35088a07d0 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.MoveTypeToFile/MoveTypeToFileRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.MoveTypeToFile/MoveTypeToFileRefactoring.cs
@@ -109,13 +109,13 @@ namespace MonoDevelop.Refactoring.MoveTypeToFile
start = data.Document.GetLine (startLine).Offset;
} else {
var startLocation = typeFilterTransformer.TypeDeclaration.StartLocation;
- startLocation.Column = 0;
+ startLocation.Column = 1;
foreach (var attr in typeFilterTransformer.TypeDeclaration.Attributes) {
if (attr.StartLocation < startLocation)
startLocation = attr.StartLocation;
}
- start = data.Document.LocationToOffset (startLocation.Line - 1, 0);
+ start = data.Document.LocationToOffset (startLocation.Line, 1);
}
int length = data.Document.LocationToOffset (typeFilterTransformer.TypeDeclaration.EndLocation.Line - 1, typeFilterTransformer.TypeDeclaration.EndLocation.Column) - start;
@@ -123,12 +123,12 @@ namespace MonoDevelop.Refactoring.MoveTypeToFile
TypeSearchVisitor typeSearchVisitor = new TypeSearchVisitor ();
generatedCompilationUnit.AcceptVisitor (typeSearchVisitor, null);
- int genStart = generatedDocument.LocationToOffset (typeSearchVisitor.Types[0].StartLocation.Line - 1, 0);
+ int genStart = generatedDocument.LocationToOffset (typeSearchVisitor.Types[0].StartLocation.Line, 0);
foreach (var attr in typeSearchVisitor.Types[0].Attributes) {
- genStart = Math.Min (genStart, generatedDocument.LocationToOffset (attr.StartLocation.Line - 1, 0));
+ genStart = Math.Min (genStart, generatedDocument.LocationToOffset (attr.StartLocation.Line, 0));
}
- int genEnd = generatedDocument.LocationToOffset (typeSearchVisitor.Types[0].EndLocation.Line - 1, typeSearchVisitor.Types[0].EndLocation.Column - 1);
+ int genEnd = generatedDocument.LocationToOffset (typeSearchVisitor.Types[0].EndLocation.Line, typeSearchVisitor.Types[0].EndLocation.Column);
((Mono.TextEditor.IBuffer)generatedDocument).Replace (genStart, genEnd - genStart, data.Document.GetTextAt (start, length));
content.Append (generatedDocument.Text);
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/FindTypeReferencesVisitor.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/FindTypeReferencesVisitor.cs
index d86f176ade..e95184d305 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/FindTypeReferencesVisitor.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/FindTypeReferencesVisitor.cs
@@ -76,12 +76,12 @@ namespace MonoDevelop.Refactoring.RefactorImports
{
string invocation = "";
if (!invocationExpression.StartLocation.IsEmpty && !invocationExpression.EndLocation.IsEmpty) {
- invocation = this.data.Document.GetTextBetween (this.data.Document.LocationToOffset (invocationExpression.StartLocation.Line - 1, invocationExpression.StartLocation.Column - 1),
- this.data.Document.LocationToOffset (invocationExpression.EndLocation.Line - 1, invocationExpression.EndLocation.Column - 1));
+ invocation = this.data.Document.GetTextBetween (this.data.Document.LocationToOffset (invocationExpression.StartLocation.Line, invocationExpression.StartLocation.Column),
+ this.data.Document.LocationToOffset (invocationExpression.EndLocation.Line, invocationExpression.EndLocation.Column));
}
base.VisitInvocationExpression (invocationExpression, data);
- MethodResolveResult mrr = resolver.Resolve (new ExpressionResult (invocation), new DomLocation (invocationExpression.StartLocation.Line - 1, invocationExpression.StartLocation.Column - 1)) as MethodResolveResult;
+ MethodResolveResult mrr = resolver.Resolve (new ExpressionResult (invocation), new DomLocation (invocationExpression.StartLocation.Line, invocationExpression.StartLocation.Column)) as MethodResolveResult;
if (mrr != null && mrr.MostLikelyMethod != null && mrr.MostLikelyMethod is ExtensionMethod) {
IMethod originalMethod = ((ExtensionMethod)mrr.MostLikelyMethod).OriginalMethod;
possibleTypeReferences.Add (new TypeReference (originalMethod.DeclaringType.Name));
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/RemoveUnusedImportsRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/RemoveUnusedImportsRefactoring.cs
index 7ae4d29750..af5a039758 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/RemoveUnusedImportsRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/RemoveUnusedImportsRefactoring.cs
@@ -73,8 +73,8 @@ namespace MonoDevelop.Refactoring.RefactorImports
if (!u.Aliases.Any () && u.Namespaces.All (name => currentUsings.Contains (name) || !usedUsings.Contains (name)) ) {
TextReplaceChange change = new TextReplaceChange ();
change.FileName = options.Document.FileName;
- change.Offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line - 1, u.Region.Start.Column - 1);
- change.RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line - 1, u.Region.End.Column - 1) - change.Offset;
+ change.Offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line, u.Region.Start.Column);
+ change.RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line, u.Region.End.Column) - change.Offset;
Mono.TextEditor.LineSegment line = textEditorData.Document.GetLineByOffset (change.Offset);
if (line != null && line.EditableLength == change.RemovedChars)
change.RemovedChars += line.DelimiterLength;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/SortImportsRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/SortImportsRefactoring.cs
index 44a5b753e3..fbee48ec57 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/SortImportsRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/SortImportsRefactoring.cs
@@ -73,11 +73,11 @@ namespace MonoDevelop.Refactoring.RefactorImports
foreach (IUsing u in compilationUnit.Usings) {
if (u.IsFromNamespace)
continue;
- int offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line - 1, u.Region.Start.Column - 1);
+ int offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line, u.Region.Start.Column);
TextReplaceChange change = new TextReplaceChange () {
FileName = options.Document.FileName,
Offset = offset,
- RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line - 1, u.Region.End.Column - 1) - offset
+ RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line, u.Region.End.Column) - offset
};
Mono.TextEditor.LineSegment line = textEditorData.Document.GetLineByOffset (change.Offset);
if (line != null && line.EditableLength == change.RemovedChars)
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs
index 891e1376fc..6c2e799413 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs
@@ -90,10 +90,10 @@ namespace MonoDevelop.Refactoring.Rename
TextLink link = new TextLink ("name");
int baseOffset = Int32.MaxValue;
foreach (MemberReference r in col) {
- baseOffset = Math.Min (baseOffset, data.Document.LocationToOffset (r.Line - 1, r.Column - 1));
+ baseOffset = Math.Min (baseOffset, data.Document.LocationToOffset (r.Line, r.Column));
}
foreach (MemberReference r in col) {
- Segment segment = new Segment (data.Document.LocationToOffset (r.Line - 1, r.Column - 1) - baseOffset, r.Name.Length);
+ Segment segment = new Segment (data.Document.LocationToOffset (r.Line, r.Column) - baseOffset, r.Name.Length);
if (segment.Offset <= data.Caret.Offset - baseOffset && data.Caret.Offset - baseOffset <= segment.EndOffset) {
link.Links.Insert (0, segment);
} else {
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/HelperMethods.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/HelperMethods.cs
index 53c52b8b6d..f2b29a7c1f 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/HelperMethods.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/HelperMethods.cs
@@ -42,7 +42,7 @@ namespace MonoDevelop.Refactoring
public static DocumentLocation ToDocumentLocation (this DomLocation location, Document document)
{
- return new DocumentLocation (location.Line - 1, location.Column - 1);
+ return new DocumentLocation (location.Line, location.Column);
}
public static TypeReference ConvertToTypeReference (this MonoDevelop.Projects.Dom.IReturnType returnType)
@@ -97,7 +97,7 @@ namespace MonoDevelop.Refactoring
throw new ArgumentNullException ("type");
List<InsertionPoint> result = new List<InsertionPoint> ();
- int offset = doc.LocationToOffset (type.BodyRegion.Start.Line - 1, type.BodyRegion.Start.Column);
+ int offset = doc.LocationToOffset (type.BodyRegion.Start.Line, type.BodyRegion.Start.Column);
if (offset < 0)
return result;
while (offset < doc.Length && doc.GetCharAt (offset) != '{' && char.IsWhiteSpace (doc.GetCharAt (offset)))
@@ -108,12 +108,12 @@ namespace MonoDevelop.Refactoring
foreach (IMember member in type.Members) {
DomLocation domLocation = member.BodyRegion.End;
if (domLocation.Line <= 0) {
- LineSegment lineSegment = doc.GetLine (member.Location.Line - 1);
+ LineSegment lineSegment = doc.GetLine (member.Location.Line);
if (lineSegment == null)
continue;
domLocation = new DomLocation (member.Location.Line, lineSegment.EditableLength + 1);
}
- result.Add (GetInsertionPosition (doc, domLocation.Line - 1, domLocation.Column - 1));
+ result.Add (GetInsertionPosition (doc, domLocation.Line, domLocation.Column));
}
result[result.Count - 1].LineAfter = NewLineInsertion.None;
CheckStartPoint (doc, result[0], result.Count == 1);
@@ -128,9 +128,9 @@ namespace MonoDevelop.Refactoring
if (line == null)
return;
- if (doc.GetLineIndent (line).Length < point.Location.Column)
+ if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
point.LineBefore = NewLineInsertion.BlankLine;
- if (point.Location.Column < line.EditableLength)
+ if (point.Location.Column < line.EditableLength + 1)
point.LineAfter = NewLineInsertion.Eol;
}
@@ -139,18 +139,18 @@ namespace MonoDevelop.Refactoring
LineSegment line = doc.GetLine (point.Location.Line);
if (line == null)
return;
- if (doc.GetLineIndent (line).Length == point.Location.Column) {
+ if (doc.GetLineIndent (line).Length + 1 == point.Location.Column) {
int lineNr = point.Location.Line;
- while (lineNr > 0 && doc.GetLineIndent (lineNr - 1).Length == doc.GetLine (lineNr - 1).EditableLength) {
+ while (lineNr > 1 && doc.GetLineIndent (lineNr - 1).Length == doc.GetLine (lineNr - 1).EditableLength) {
lineNr--;
}
line = doc.GetLine (lineNr);
- point.Location = new DocumentLocation (lineNr, doc.GetLineIndent (line).Length);
+ point.Location = new DocumentLocation (lineNr, doc.GetLineIndent (line).Length + 1);
}
- if (doc.GetLineIndent (line).Length < point.Location.Column)
+ if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
point.LineBefore = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
- if (point.Location.Column < line.EditableLength)
+ if (point.Location.Column < line.EditableLength + 1)
point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
}
@@ -176,7 +176,7 @@ namespace MonoDevelop.Refactoring
if (nextLine == null)
return new InsertionPoint (doc.OffsetToLocation (bodyEndOffset - 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
int oldLine = line;
- while (line + 1 < doc.LineCount && doc.GetLineIndent (line + 1).Length == doc.GetLine (line + 1).EditableLength)
+ while (line < doc.LineCount && doc.GetLineIndent (line + 1).Length == doc.GetLine (line + 1).EditableLength)
line++;
NewLineInsertion insertBefore = NewLineInsertion.None;
NewLineInsertion insertAfter = NewLineInsertion.None;
@@ -196,7 +196,7 @@ namespace MonoDevelop.Refactoring
insertAfter = NewLineInsertion.None;
}
- return new InsertionPoint (new DocumentLocation (lineNumber, doc.GetLineIndent (lineNumber).Length), insertBefore, insertAfter);
+ return new InsertionPoint (new DocumentLocation (lineNumber, doc.GetLineIndent (lineNumber).Length + 1), insertBefore, insertAfter);
}
}
}
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringOptions.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringOptions.cs
index d2a422fefd..0ef22c1424 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringOptions.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringOptions.cs
@@ -100,8 +100,8 @@ namespace MonoDevelop.Refactoring
if (provider == null)
return null;
- int start = Document.Editor.Document.LocationToOffset (member.BodyRegion.Start.Line - 1, member.BodyRegion.Start.Column - 1);
- int end = Document.Editor.Document.LocationToOffset (member.BodyRegion.End.Line - 1, member.BodyRegion.End.Column - 1);
+ int start = Document.Editor.Document.LocationToOffset (member.BodyRegion.Start.Line, member.BodyRegion.Start.Column);
+ int end = Document.Editor.Document.LocationToOffset (member.BodyRegion.End.Line, member.BodyRegion.End.Column);
string memberBody = Document.Editor.GetTextBetween (start, end);
return provider.ParseText (memberBody);
}
@@ -122,7 +122,7 @@ namespace MonoDevelop.Refactoring
public static string GetIndent (Document document, IMember member)
{
- return GetWhitespaces (document, document.Editor.Document.LocationToOffset (member.Location.Line - 1, 0));
+ return GetWhitespaces (document, document.Editor.Document.LocationToOffset (member.Location.Line, 1));
}
public string GetWhitespaces (int insertionOffset)
{
@@ -136,7 +136,7 @@ namespace MonoDevelop.Refactoring
public IReturnType ShortenTypeName (IReturnType fullyQualifiedTypeName)
{
- return Document.ParsedDocument.CompilationUnit.ShortenTypeName (fullyQualifiedTypeName, Document.Editor.Caret.Line + 1, Document.Editor.Caret.Column + 1);
+ return Document.ParsedDocument.CompilationUnit.ShortenTypeName (fullyQualifiedTypeName, Document.Editor.Caret.Line, Document.Editor.Caret.Column);
}
public ParsedDocument ParseDocument ()
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs
index 846febf1e7..7c8993b17d 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoryCommands.cs
@@ -518,7 +518,7 @@ namespace MonoDevelop.Refactoring
public void ResolveName ()
{
// TODO: Move this to a expression refactorer !!!!
- int pos = doc.Editor.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.Start.Line - 1, resolveResult.ResolvedExpression.Region.Start.Column - 1);
+ int pos = doc.Editor.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.Start.Line, resolveResult.ResolvedExpression.Region.Start.Column);
doc.Editor.Insert (pos, ns +"." );
}
}
@@ -836,7 +836,7 @@ namespace MonoDevelop.Refactoring
System.IO.TextReader textReader = provider.Open ();
doc.Text = textReader.ReadToEnd ();
textReader.Close ();
- int position = doc.LocationToOffset (part.Location.Line - 1, part.Location.Column - 1);
+ int position = doc.LocationToOffset (part.Location.Line, part.Location.Column);
while (position + part.Name.Length < doc.Length) {
if (doc.GetTextAt (position, part.Name.Length) == part.Name)
break;
diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ReferencesFinder.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ReferencesFinder.cs
index 27c76ed43d..1d47804216 100644
--- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ReferencesFinder.cs
+++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/ReferencesFinder.cs
@@ -111,7 +111,7 @@ namespace MonoDevelop.Refactoring.References
var resolver = ProjectDomService.GetParser (fileInfo.FileName).CreateResolver (fileInfo.Dom, data, fileInfo.FileName);
var location = data.Document.OffsetToLocation (match.Offset);
- ResolveResult resolveResult = resolver.Resolve (expr, new DomLocation (location.Line + 1, location.Column + 1));
+ ResolveResult resolveResult = resolver.Resolve (expr, new DomLocation (location.Line, location.Column));
// TODO: Add IsReferenceTo in the resolve results - could could be taken from FindMemberAstVisitor
if (resolveResult != null && resolveResult.IsReferenceTo (member))
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueTooltipProvider.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueTooltipProvider.cs
index a8d981960a..d2ba216cfa 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueTooltipProvider.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DebugValueTooltipProvider.cs
@@ -82,8 +82,8 @@ namespace MonoDevelop.SourceEditor
if (expression == null)*/
if (res != null && res.ResolvedExpression != null) {
expression = res.ResolvedExpression.Expression;
- startOffset = editor.Document.LocationToOffset (res.ResolvedExpression.Region.Start.Line - 1, res.ResolvedExpression.Region.Start.Column - 1);
- int endOffset = editor.Document.LocationToOffset (res.ResolvedExpression.Region.End.Line - 1, res.ResolvedExpression.Region.End.Column - 1);
+ startOffset = editor.Document.LocationToOffset (res.ResolvedExpression.Region.Start.Line, res.ResolvedExpression.Region.Start.Column);
+ int endOffset = editor.Document.LocationToOffset (res.ResolvedExpression.Region.End.Line, res.ResolvedExpression.Region.End.Column);
length = endOffset - startOffset;
}
}
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DefaultFormatter.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DefaultFormatter.cs
index bd6c188906..99714fd6ad 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DefaultFormatter.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/DefaultFormatter.cs
@@ -44,8 +44,8 @@ namespace MonoDevelop.SourceEditor
static int GetNextTabstop (int currentColumn, int tabSize)
{
- int result = currentColumn + tabSize;
- return (result / tabSize) * tabSize;
+ int result = currentColumn - 1 + tabSize;
+ return 1 + (result / tabSize) * tabSize;
}
protected override string InternalFormat (PolicyContainer policyParent, string mimeType, string input, int startOffset, int endOffset)
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/GotoLineNumberWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/GotoLineNumberWidget.cs
index a6b6d6e2fb..bee78707fe 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/GotoLineNumberWidget.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/GotoLineNumberWidget.cs
@@ -141,7 +141,7 @@ namespace MonoDevelop.SourceEditor
line = entryLineNumber.Text.Trim ().StartsWith ("-") ? int.MinValue : int.MaxValue;
}
bool isRelativeJump = entryLineNumber.Text.Trim ().StartsWith ("-") || entryLineNumber.Text.Trim ().StartsWith ("+");
- return isRelativeJump ? this.caretSave.Line + line : line - 1;
+ return isRelativeJump ? this.caretSave.Line + line : line;
}
}
@@ -167,7 +167,7 @@ namespace MonoDevelop.SourceEditor
try {
int targetLine = TargetLine;
if (targetLine >= widget.TextEditor.Document.LineCount || targetLine < 0) {
- targetLine = Math.Max (0, Math.Min (widget.TextEditor.Document.LineCount - 1, targetLine));
+ targetLine = Math.Max (1, Math.Min (widget.TextEditor.Document.LineCount, targetLine));
} else {
this.entryLineNumber.ModifyBase (Gtk.StateType.Normal, Style.Base (Gtk.StateType.Normal));
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/LanguageItemTooltipProvider.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/LanguageItemTooltipProvider.cs
index 90df254fa7..7ca0d6b1ff 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/LanguageItemTooltipProvider.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/LanguageItemTooltipProvider.cs
@@ -48,10 +48,10 @@ namespace MonoDevelop.SourceEditor
ResolveResult resolveResult = ed.GetLanguageItem (offset);
if (resolveResult == null || resolveResult.ResolvedExpression == null)
return null;
- int startOffset = editor.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.Start.Line - 1,
- resolveResult.ResolvedExpression.Region.Start.Column - 1);
- int endOffset = editor.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.End.Line - 1,
- resolveResult.ResolvedExpression.Region.End.Column - 1);
+ int startOffset = editor.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.Start.Line,
+ resolveResult.ResolvedExpression.Region.Start.Column);
+ int endOffset = editor.Document.LocationToOffset (resolveResult.ResolvedExpression.Region.End.Line,
+ resolveResult.ResolvedExpression.Region.End.Column);
return new TooltipItem (resolveResult, startOffset, endOffset - startOffset);
}
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
index 99f4533a1e..b88ae68dbc 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
@@ -250,7 +250,7 @@ namespace MonoDevelop.SourceEditor
Task task = e.Tasks.FirstOrDefault ();
if (task == null || task.FileName != Document.FileName)
return;
- LineSegment lineSegment = Document.GetLine (task.Line - 1);
+ LineSegment lineSegment = Document.GetLine (task.Line);
if (lineSegment == null)
return;
MessageBubbleTextMarker marker = (MessageBubbleTextMarker)lineSegment.Markers.FirstOrDefault (m => m is MessageBubbleTextMarker);
@@ -301,7 +301,7 @@ namespace MonoDevelop.SourceEditor
if (task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning) {
if (IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrors && task.Severity == TaskSeverity.Warning)
continue;
- LineSegment lineSegment = widget.Document.GetLine (task.Line - 1);
+ LineSegment lineSegment = widget.Document.GetLine (task.Line);
if (lineSegment == null)
continue;
var marker = currentErrorMarkers.FirstOrDefault (m => m.LineSegment == lineSegment);
@@ -657,7 +657,7 @@ namespace MonoDevelop.SourceEditor
}
}
if (lines != 0)
- TextFileService.FireLineCountChanged (this, location.Line + 1, lines, location.Column + 1);
+ TextFileService.FireLineCountChanged (this, location.Line, lines, location.Column);
}
void OnCurrentFrameChanged (object s, EventArgs args)
@@ -677,7 +677,7 @@ namespace MonoDevelop.SourceEditor
return;
RemoveDebugMarkers ();
lastDebugLine = frame.SourceLocation.Line;
- var segment = widget.TextEditor.Document.GetLine (lastDebugLine-1);
+ var segment = widget.TextEditor.Document.GetLine (lastDebugLine);
if (segment != null) {
if (DebuggingService.CurrentFrameIndex == 0) {
currentLineSegment = segment;
@@ -743,13 +743,13 @@ namespace MonoDevelop.SourceEditor
void AddWatch (PinnedWatch w)
{
- LineSegment line = widget.TextEditor.Document.GetLine (w.Line - 1);
+ LineSegment line = widget.TextEditor.Document.GetLine (w.Line);
if (line == null)
return;
PinnedWatchInfo wi = new PinnedWatchInfo ();
wi.Line = line;
if (w.OffsetX < 0) {
- w.OffsetY = (int)widget.TextEditor.LineToY (w.Line - 1);
+ w.OffsetY = (int)widget.TextEditor.LineToY (w.Line);
int lw, lh;
widget.TextEditor.TextViewMargin.GetLayout (line).Layout.GetPixelSize (out lw, out lh);
w.OffsetX = (int)widget.TextEditor.TextViewMargin.XOffset + lw + 4;
@@ -809,7 +809,7 @@ namespace MonoDevelop.SourceEditor
count++;
if (i < breakpointSegments.Count) {
int lineNumber = widget.TextEditor.Document.OffsetToLineNumber (breakpointSegments[i].Offset);
- if (lineNumber != bp.Line - 1) {
+ if (lineNumber != bp.Line) {
mismatch = true;
break;
}
@@ -832,7 +832,7 @@ namespace MonoDevelop.SourceEditor
breakpointSegments.Clear ();
foreach (Breakpoint bp in DebuggingService.Breakpoints.GetBreakpoints ()) {
- lineNumbers.Add (bp.Line - 1);
+ lineNumbers.Add (bp.Line);
AddBreakpoint (bp);
}
@@ -853,7 +853,7 @@ namespace MonoDevelop.SourceEditor
return;
FilePath fp = Name;
if (fp.FullPath == bp.FileName) {
- LineSegment line = widget.TextEditor.Document.GetLine (bp.Line-1);
+ LineSegment line = widget.TextEditor.Document.GetLine (bp.Line);
if (line == null)
return;
@@ -924,7 +924,7 @@ namespace MonoDevelop.SourceEditor
} else if (args.Button == 1) {
if (!string.IsNullOrEmpty (this.Document.FileName)) {
if (args.LineSegment != null)
- DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber + 1);
+ DebuggingService.Breakpoints.Toggle (this.Document.FileName, args.LineNumber);
}
}
}
@@ -988,12 +988,12 @@ namespace MonoDevelop.SourceEditor
public void SetCaretTo (int line, int column)
{
- widget.TextEditor.SetCaretTo (line - 1, column - 1, true);
+ widget.TextEditor.SetCaretTo (line, column, true);
}
public void SetCaretTo (int line, int column, bool highlight)
{
- widget.TextEditor.SetCaretTo (line - 1, column - 1, highlight);
+ widget.TextEditor.SetCaretTo (line, column, highlight);
}
public void Redo()
@@ -1120,13 +1120,13 @@ namespace MonoDevelop.SourceEditor
public int GetPositionFromLineColumn (int line, int column)
{
- return this.widget.TextEditor.Document.LocationToOffset (new DocumentLocation (line - 1, column - 1));
+ return this.widget.TextEditor.Document.LocationToOffset (new DocumentLocation (line, column));
}
public void GetLineColumnFromPosition (int position, out int line, out int column)
{
DocumentLocation location = this.widget.TextEditor.Document.OffsetToLocation (position);
- line = location.Line + 1;
- column = location.Column + 1;
+ line = location.Line;
+ column = location.Column;
}
#endregion
@@ -1291,8 +1291,8 @@ namespace MonoDevelop.SourceEditor
CodeCompletionContext result = new CodeCompletionContext ();
result.TriggerOffset = triggerOffset;
DocumentLocation loc = Document.OffsetToLocation (triggerOffset);
- result.TriggerLine = loc.Line + 1;
- result.TriggerLineOffset = loc.Column + 1;
+ result.TriggerLine = loc.Line;
+ result.TriggerLineOffset = loc.Column - 1;
var p = DocumentToScreenLocation (loc);
result.TriggerXCoord = p.X;
result.TriggerYCoord = p.Y;
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
index 41ef37356f..0a125a0dbd 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
@@ -334,13 +334,13 @@ namespace MonoDevelop.SourceEditor
{
Document document = textEditorData.Document;
if (document == null || region.Start.Line <= 0 || region.End.Line <= 0
- || region.Start.Line >= document.LineCount || region.End.Line >= document.LineCount)
+ || region.Start.Line > document.LineCount || region.End.Line > document.LineCount)
{
return null;
}
- int startOffset = document.LocationToOffset (region.Start.Line - 1, region.Start.Column - 1);
- int endOffset = document.LocationToOffset (region.End.Line - 1, region.End.Column - 1);
+ int startOffset = document.LocationToOffset (region.Start.Line, region.Start.Column);
+ int endOffset = document.LocationToOffset (region.End.Line, region.End.Column );
FoldSegment result = new FoldSegment (document, text, startOffset, endOffset - startOffset, type);
foldSegments.Add (result);
@@ -538,7 +538,7 @@ namespace MonoDevelop.SourceEditor
if (errors.ContainsKey (info.Region.Start.Line - 1))
return;
- LineSegment line = this.TextEditor.Document.GetLine (info.Region.Start.Line - 1);
+ LineSegment line = this.TextEditor.Document.GetLine (info.Region.Start.Line);
ErrorMarker error = new ErrorMarker (info, line);
errors [info.Region.Start.Line - 1] = error;
error.AddToLine (this.TextEditor.Document);
@@ -1451,9 +1451,9 @@ namespace MonoDevelop.SourceEditor
underlineColor = Mono.TextEditor.Highlighting.Style.ErrorUnderlineString;
if (Info.Region.Start.Line == info.Region.End.Line)
- marker = new UnderlineMarker (underlineColor, Info.Region.Start.Column - 1, info.Region.End.Column - 1);
+ marker = new UnderlineMarker (underlineColor, Info.Region.Start.Column, info.Region.End.Column);
else
- marker = new UnderlineMarker (underlineColor, - 1, - 1);
+ marker = new UnderlineMarker (underlineColor, 0, 0);
}
public void AddToLine (Mono.TextEditor.Document doc)
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StatusBox.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StatusBox.cs
index dde0f21048..0090ad42e4 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StatusBox.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StatusBox.cs
@@ -116,15 +116,15 @@ namespace MonoDevelop.SourceEditor
string GetText (bool showMax)
{
- int line = showMax ? Editor.Document.LineCount : Editor.TextEditor.Caret.Line + 1;
+ int line = showMax ? Editor.Document.LineCount : Editor.TextEditor.Caret.Line;
int column;
if (showMax) {
column = System.Math.Max (Editor.TextEditor.Caret.Column, 100);
} else if (ShowRealColumns) {
DocumentLocation location = Editor.TextEditor.LogicalToVisualLocation (Editor.TextEditor.Caret.Location);
- column = location.Column + 1;
+ column = location.Column;
} else {
- column = Editor.TextEditor.Caret.Column + 1;
+ column = Editor.TextEditor.Caret.Column ;
}
return string.Format (ShowRealColumns ? GettextCatalog.GetString ("Line: {0}, Column: {1}") : "{0} : {1}", line, column);
diff --git a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Gui/BaseXmlEditorExtension.cs b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Gui/BaseXmlEditorExtension.cs
index 0b256630c4..b5982e34c1 100644
--- a/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Gui/BaseXmlEditorExtension.cs
+++ b/main/src/addins/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.Gui/BaseXmlEditorExtension.cs
@@ -546,8 +546,8 @@ namespace MonoDevelop.XmlEditor.Gui
protected void EditorSelect (DomRegion region)
{
- int s = Editor.Document.LocationToOffset (region.Start.Line - 1, region.Start.Column - 1);
- int e = Editor.Document.LocationToOffset (region.End.Line - 1, region.End.Column - 1);
+ int s = Editor.Document.LocationToOffset (region.Start.Line, region.Start.Column);
+ int e = Editor.Document.LocationToOffset (region.End.Line, region.End.Column);
if (s > -1 && e > s) {
Editor.SetSelection (s, e);
Editor.ScrollTo (s);
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
index 335b0075b9..1b6aae1320 100644
--- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
+++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Gui/T4EditorExtension.cs
@@ -274,7 +274,7 @@ namespace MonoDevelop.TextTemplating.Gui
void SelectSegment (Mono.TextTemplating.ISegment seg)
{
- int s = Editor.Document.LocationToOffset (seg.TagStartLocation.Line - 1, seg.TagStartLocation.Column - 1);
+ int s = Editor.Document.LocationToOffset (seg.TagStartLocation.Line, seg.TagStartLocation.Column);
if (s > -1) {
Editor.Caret.Offset = s;
Editor.CenterTo (s);
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
index 51f1ed35e9..a65b97e6ac 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
@@ -433,10 +433,10 @@ namespace MonoDevelop.VersionControl.Views
lineCount = Math.Min (lineCount, annotations.Count - startLine);
if (lineCount > 0)
- annotations.RemoveRange (startLine, lineCount);
+ annotations.RemoveRange (startLine - 1, lineCount);
if (!string.IsNullOrEmpty (e.Value)) {
for (int i=0; i<lineCount; ++i)
- annotations.Insert (startLine, locallyModified);
+ annotations.Insert (startLine - 1, locallyModified);
}
return;
} else if (0 == e.Count) {
@@ -444,7 +444,7 @@ namespace MonoDevelop.VersionControl.Views
tokens = e.Value.Split (new string[]{Environment.NewLine}, StringSplitOptions.None);
lineCount = tokens.Length - 1;
for (int i=0; i<lineCount; ++i) {
- annotations.Insert (Math.Min (startLine + 1, annotations.Count), locallyModified);
+ annotations.Insert (Math.Min (startLine, annotations.Count), locallyModified);
}
} else if (startLine > endLine) {
// revert
@@ -516,7 +516,7 @@ namespace MonoDevelop.VersionControl.Views
int startLine = widget.Editor.YToLine ((int)widget.Editor.VAdjustment.Value);
double startY = widget.Editor.LineToY (startLine);
- while (startLine > 0 && startLine < annotations.Count && annotations[startLine - 1] != null && annotations[startLine] != null && annotations[startLine - 1].Revision == annotations[startLine].Revision) {
+ while (startLine > 1 && startLine < annotations.Count && annotations[startLine - 1] != null && annotations[startLine] != null && annotations[startLine - 1].Revision == annotations[startLine].Revision) {
startLine--;
startY -= widget.Editor.GetLineHeight (widget.Editor.Document.GetLine (startLine));
}
@@ -528,7 +528,7 @@ namespace MonoDevelop.VersionControl.Views
widget.JumpOverFoldings (ref line);
int lineStart = line;
int w = 0, w2 = 0, h = 16;
- Annotation ann = line < annotations.Count ? annotations[line] : null;
+ Annotation ann = line <= annotations.Count ? annotations[line - 1] : null;
if (ann != null) {
layout.SetText (ann.Author);
layout.GetPixelSize (out w, out h);
@@ -552,7 +552,7 @@ namespace MonoDevelop.VersionControl.Views
curY += lineHeight;
line++;
widget.JumpOverFoldings (ref line);
- } while (line + 1 < annotations.Count && annotations[line] != null && annotations[line].Revision == ann.Revision);
+ } while (line + 1 <= annotations.Count && annotations[line - 1] != null && annotations[line - 1].Revision == ann.Revision);
} else {
curY += widget.Editor.GetLineHeight (line);
line++;
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs
index a8c871a0f2..61f71c143c 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/ComparisonWidget.cs
@@ -1,3 +1,4 @@
+
//
// ComparisonWidget.cs
//
@@ -23,6 +24,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+
using System;
using System.Linq;
using Gtk;
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs
index 19f0c53366..60e93a4c7d 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs
@@ -301,7 +301,7 @@ namespace MonoDevelop.VersionControl.Views
int start = useRemove ? hunk.RemoveStart : hunk.InsertStart;
int count = useRemove ? hunk.Removed : hunk.Inserted;
for (int i = 0; i < count; i++) {
- var word = words[start + i];
+ var word = words[start + i - 1];
if (endOffset != word.Offset) {
if (startOffset >= 0)
result.Add (GetDiffRectangle (editor, startOffset, endOffset));
@@ -404,8 +404,8 @@ namespace MonoDevelop.VersionControl.Views
if (offset < 0 || offset > caret.TextEditorData.Document.Length)
return;
DocumentLocation location = caret.TextEditorData.LogicalToVisualLocation (caret.Location);
- IdeApp.Workbench.StatusBar.ShowCaretState (caret.Line + 1,
- location.Column + 1,
+ IdeApp.Workbench.StatusBar.ShowCaretState (caret.Line,
+ location.Column,
caret.TextEditorData.IsSomethingSelected ? caret.TextEditorData.SelectionRange.Length : 0,
caret.IsInInsertMode);
}
@@ -634,14 +634,14 @@ namespace MonoDevelop.VersionControl.Views
var start = toEditor.Document.GetLine (hunk.InsertStart);
int toOffset = start != null ? start.Offset : toEditor.Document.Length;
if (start != null && hunk.Inserted > 0) {
- int line = Math.Min (hunk.InsertStart + hunk.Inserted - 1, toEditor.Document.LineCount - 1);
+ int line = Math.Min (hunk.InsertStart + hunk.Inserted, toEditor.Document.LineCount);
var end = toEditor.Document.GetLine (line);
toEditor.Remove (start.Offset, end.EndOffset - start.Offset);
}
if (hunk.Removed > 0) {
- start = fromEditor.Document.GetLine (Math.Min (hunk.RemoveStart, fromEditor.Document.LineCount - 1));
- int line = Math.Min (hunk.RemoveStart + hunk.Removed - 1, fromEditor.Document.LineCount - 1);
+ start = fromEditor.Document.GetLine (Math.Min (hunk.RemoveStart, fromEditor.Document.LineCount));
+ int line = Math.Min (hunk.RemoveStart + hunk.Removed, fromEditor.Document.LineCount);
var end = fromEditor.Document.GetLine (line);
toEditor.Insert (toOffset, start.Offset == end.EndOffset ? toEditor.EolMarker : fromEditor.Document.GetTextBetween (start.Offset, end.EndOffset));
}
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs
index ca81263964..0131c6a230 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/MergeWidget.cs
@@ -198,14 +198,14 @@ namespace MonoDevelop.VersionControl.Views
string above = MainEditor.Document.GetTextBetween (curOffset, conflict.StartSegment.Offset);
editors[0].Insert (editors[0].Document.Length, above);
- int leftA = editors[0].Document.LineCount - 1;
+ int leftA = editors[0].Document.LineCount;
editors[0].Insert (editors[0].Document.Length, MainEditor.Document.GetTextAt (conflict.MySegment));
- int leftB = editors[0].Document.LineCount - 1;
+ int leftB = editors[0].Document.LineCount;
editors[2].Insert (editors[2].Document.Length, above);
- int rightA = editors[2].Document.LineCount - 1;
+ int rightA = editors[2].Document.LineCount;
editors[2].Insert (editors[2].Document.Length, MainEditor.Document.GetTextAt (conflict.TheirSegment));
- int rightB = editors[2].Document.LineCount - 1;
+ int rightB = editors[2].Document.LineCount;
try {
MainEditor.Remove (conflict.EndSegment);
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Utils/Diff.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Utils/Diff.cs
index ee561c2572..dbd21b6657 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Utils/Diff.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Utils/Diff.cs
@@ -101,11 +101,11 @@ namespace Mono.TextEditor.Utils
{
public struct Hunk
{
- public static readonly Hunk Empty = new Hunk (-1, -1, 0, 0);
+ public static readonly Hunk Empty = new Hunk (0, 0, 0, 0);
public bool IsEmpty {
get {
- return InsertStart < 0;
+ return InsertStart <= 0;
}
}
@@ -241,7 +241,7 @@ namespace Mono.TextEditor.Utils
if (startA < lineA || startB < lineB) {
// store a new difference-item
- yield return new Hunk (startA, startB, lineA - startA, lineB - startB);
+ yield return new Hunk (startA + 1, startB + 1, lineA - startA, lineB - startB);
}
// if
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViActions.cs
index 6d59b9110d..1e1d5404c9 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViActions.cs
@@ -37,14 +37,14 @@ namespace Mono.TextEditor.Vi
{
public static void MoveToNextEmptyLine (TextEditorData data)
{
- if (data.Caret.Line == data.Document.LineCount - 1) {
+ if (data.Caret.Line == data.Document.LineCount) {
data.Caret.Offset = data.Document.Length;
return;
}
int line = data.Caret.Line + 1;
LineSegment currentLine = data.Document.GetLine (line);
- while (line < data.Document.LineCount - 1) {
+ while (line < data.Document.LineCount) {
line++;
LineSegment nextLine = data.Document.GetLine (line);
if (currentLine.EditableLength != 0 && nextLine.EditableLength == 0) {
@@ -59,14 +59,14 @@ namespace Mono.TextEditor.Vi
public static void MoveToPreviousEmptyLine (TextEditorData data)
{
- if (data.Caret.Line == 0) {
+ if (data.Caret.Line == DocumentLocation.MinLine) {
data.Caret.Offset = 0;
return;
}
int line = data.Caret.Line - 1;
LineSegment currentLine = data.Document.GetLine (line);
- while (line > 0) {
+ while (line > DocumentLocation.MinLine) {
line--;
LineSegment previousLine = data.Document.GetLine (line);
if (currentLine.EditableLength != 0 && previousLine.EditableLength == 0) {
@@ -88,7 +88,7 @@ namespace Mono.TextEditor.Vi
public static void NewLineAbove (TextEditorData data)
{
- if (data.Caret.Line == 0) {
+ if (data.Caret.Line == DocumentLocation.MinLine ) {
data.Caret.Offset = 0;
MiscActions.InsertNewLine (data);
data.Caret.Offset = 0;
@@ -115,7 +115,7 @@ namespace Mono.TextEditor.Vi
if (endLine == startLine)
endLine++;
- if (endLine >= data.Document.LineCount)
+ if (endLine > data.Document.LineCount)
return;
LineSegment seg = data.Document.GetLine (startLine);
@@ -159,7 +159,7 @@ namespace Mono.TextEditor.Vi
ch = Char.ToLower (ch);
int length = data.Replace (data.Caret.Offset, 1, new string (ch, 1));
LineSegment seg = data.Document.GetLine (data.Caret.Line);
- if (data.Caret.Column < seg.EditableLength - 1)
+ if (data.Caret.Column < seg.EditableLength)
data.Caret.Offset += length;
}
}
@@ -175,7 +175,7 @@ namespace Mono.TextEditor.Vi
public static void Left (TextEditorData data)
{
- if (0 < data.Caret.Column) {
+ if (DocumentLocation.MinColumn < data.Caret.Column) {
CaretMoveActions.Left (data);
}
}
@@ -228,7 +228,7 @@ namespace Mono.TextEditor.Vi
internal static void RetreatFromLineEnd (TextEditorData data)
{
if (data.Caret.Mode == CaretMode.Block && !data.IsSomethingSelected && !data.Caret.PreserveSelection) {
- while (0 < data.Caret.Column && (data.Caret.Offset >= data.Document.Length
+ while (DocumentLocation.MinLine < data.Caret.Column && (data.Caret.Offset >= data.Document.Length
|| IsEol (data.Document.GetCharAt (data.Caret.Offset)))) {
Left (data);
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViCommandBuilder.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViCommandBuilder.cs
index a6774fa508..d1cfc31117 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViCommandBuilder.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViCommandBuilder.cs
@@ -386,7 +386,7 @@ namespace Mono.TextEditor.Vi
{
var line = ed.Editor.PointToLocation (0, ed.Editor.Allocation.Height/2).Line;
if (line < 0)
- line = ed.Data.Document.LineCount - 1;
+ line = ed.Data.Document.LineCount;
ed.Data.Caret.Line = line;
}
@@ -394,7 +394,7 @@ namespace Mono.TextEditor.Vi
{
int line = ed.Editor.PointToLocation (0, ed.Editor.Allocation.Height - ed.Editor.LineHeight * 2 - 2).Line;
if (line < 0)
- line = ed.Data.Document.LineCount - 1;
+ line = ed.Data.Document.LineCount;
ed.Data.Caret.Line = line;
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViMode.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViMode.cs
index 68ed12f945..a0e3558fa0 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViMode.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Vi/ViMode.cs
@@ -199,7 +199,7 @@ namespace Mono.TextEditor.Vi
if (CaretMode.Block != data.Caret.Mode) {
data.Caret.Mode = CaretMode.Block;
- if (data.Caret.Column > 0)
+ if (data.Caret.Column > DocumentLocation.MinColumn)
data.Caret.Column--;
}
ViActions.RetreatFromLineEnd (data);
@@ -354,7 +354,7 @@ namespace Mono.TextEditor.Vi
return;
case 'x':
- if (Data.Caret.Column == Data.Document.GetLine (Data.Caret.Line).EditableLength)
+ if (Data.Caret.Column == Data.Document.GetLine (Data.Caret.Line).EditableLength + 1)
return;
Status = string.Empty;
if (!Data.IsSomethingSelected)
@@ -365,7 +365,7 @@ namespace Mono.TextEditor.Vi
return;
case 'X':
- if (Data.Caret.Column == 0)
+ if (Data.Caret.Column == DocumentLocation.MinColumn)
return;
Status = string.Empty;
if (!Data.IsSomethingSelected && 0 < Caret.Offset)
@@ -423,21 +423,21 @@ namespace Mono.TextEditor.Vi
return;
case 'H':
- Caret.Line = System.Math.Max (0, Editor.PointToLocation (0, Editor.LineHeight - 1).Line);
+ Caret.Line = System.Math.Max (DocumentLocation.MinLine, Editor.PointToLocation (0, Editor.LineHeight - 1).Line);
return;
case 'J':
RunAction (ViActions.Join);
return;
case 'L':
int line = Editor.PointToLocation (0, Editor.Allocation.Height - Editor.LineHeight * 2 - 2).Line;
- if (line < 0)
- line = Document.LineCount - 1;
+ if (line < DocumentLocation.MinLine)
+ line = Document.LineCount;
Caret.Line = line;
return;
case 'M':
line = Editor.PointToLocation (0, Editor.Allocation.Height/2).Line;
- if (line < 0)
- line = Document.LineCount - 1;
+ if (line < DocumentLocation.MinLine)
+ line = Document.LineCount;
Caret.Line = line;
return;
@@ -582,7 +582,6 @@ namespace Mono.TextEditor.Vi
case State.Replace:
action = GetInsertAction (key, modifier);
-
if (action != null)
RunAction (action);
else if (unicodeKey != 0)
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/BookmarkActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/BookmarkActions.cs
index 3d1878062f..abe724db24 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/BookmarkActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/BookmarkActions.cs
@@ -71,7 +71,7 @@ namespace Mono.TextEditor
{
int offset = GetPrevOffset (data.Document, data.Caret.Line);
if (offset < 0)
- offset = GetPrevOffset (data.Document, data.Document.LineCount - 1);
+ offset = GetPrevOffset (data.Document, data.Document.LineCount);
if (offset >= 0)
data.Caret.Offset = offset;
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Caret.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Caret.cs
index 976898cce4..f415fdba63 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Caret.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Caret.cs
@@ -31,7 +31,7 @@ namespace Mono.TextEditor
{
public class Caret
{
- DocumentLocation location;
+ DocumentLocation location = new DocumentLocation (1, 1);
bool isInInsertMode = true;
bool autoScrollToCaret = true;
@@ -44,6 +44,8 @@ namespace Mono.TextEditor
}
set {
if (location.Line != value) {
+ if (value < DocumentLocation.MinLine)
+ throw new ArgumentException ("Line < MinLine");
DocumentLocation old = location;
location.Line = value;
SetColumn ();
@@ -58,6 +60,8 @@ namespace Mono.TextEditor
}
set {
if (location.Column != value) {
+ if (value < DocumentLocation.MinColumn)
+ throw new ArgumentException ("Column < MinColumn");
DocumentLocation old = location;
location.Column = value;
SetDesiredColumn ();
@@ -72,6 +76,8 @@ namespace Mono.TextEditor
}
set {
if (location != value) {
+ if (value.Line < DocumentLocation.MinLine || value.Column < DocumentLocation.MinColumn)
+ throw new ArgumentException ("invalid location: " + value);
DocumentLocation old = location;
location = value;
SetDesiredColumn ();
@@ -83,17 +89,17 @@ namespace Mono.TextEditor
public int Offset {
get {
int result = 0;
- if (Line < TextEditorData.Document.LineCount) {
+ if (Line <= TextEditorData.Document.LineCount) {
LineSegment line = TextEditorData.Document.GetLine (Line);
if (line != null)
result = line.Offset;
- result += System.Math.Min (Column, line.EditableLength);
+ result += System.Math.Min (Column - 1, line.EditableLength);
}
return result;
}
set {
int line = TextEditorData.Document.OffsetToLineNumber (value);
- int column = value - TextEditorData.Document.GetLine (line).Offset;
+ int column = value - TextEditorData.Document.GetLine (line).Offset + 1;
Location = new DocumentLocation (line, column);
}
}
@@ -164,15 +170,15 @@ namespace Mono.TextEditor
this.TextEditorData = editor;
this.IsVisible = true;
this.AllowCaretBehindLineEnd = false;
+ this.DesiredColumn = DocumentLocation.MinColumn;
}
public void CheckCaretPosition ()
{
- if (this.Line >= TextEditorData.Document.LineCount)
- this.Line = TextEditorData.Document.LineCount - 1;
+ this.Line = System.Math.Min (this.Line, TextEditorData.Document.LineCount);
if (!AllowCaretBehindLineEnd) {
LineSegment curLine = TextEditorData.Document.GetLine (this.Line);
- this.Column = System.Math.Min (curLine.EditableLength, System.Math.Max (0, this.Column));
+ this.Column = System.Math.Min (curLine.EditableLength + 1, this.Column);
}
}
@@ -189,7 +195,7 @@ namespace Mono.TextEditor
DocumentLocation old = Location;
int line = TextEditorData.Document.OffsetToLineNumber (desiredOffset);
- int column = desiredOffset - TextEditorData.Document.GetLine (line).Offset;
+ int column = desiredOffset - TextEditorData.Document.GetLine (line).Offset + 1;
location = new DocumentLocation (line, column);
SetColumn ();
OnPositionChanged (new DocumentLocationEventArgs (old));
@@ -202,7 +208,7 @@ namespace Mono.TextEditor
return;
if (!AllowCaretBehindLineEnd)
- this.Column = System.Math.Min (curLine.EditableLength, System.Math.Max (0, this.Column));
+ this.Column = System.Math.Min (curLine.EditableLength + 1, System.Math.Max (DocumentLocation.MinColumn, this.Column));
this.DesiredColumn = curLine.GetVisualColumn (TextEditorData, this.Column);
}
@@ -215,8 +221,8 @@ namespace Mono.TextEditor
if (curLine.GetVisualColumn (TextEditorData, this.location.Column) < this.DesiredColumn) {
this.location.Column = TextEditorData.GetNextVirtualColumn (Line, this.location.Column);
} else {
- if (this.Column > curLine.EditableLength) {
- this.location.Column = System.Math.Min (curLine.EditableLength, System.Math.Max (0, this.Column));
+ if (this.Column > curLine.EditableLength + 1) {
+ this.location.Column = System.Math.Min (curLine.EditableLength + 1, System.Math.Max (DocumentLocation.MinColumn, this.Column));
if (AllowCaretBehindLineEnd)
this.location.Column = TextEditorData.GetNextVirtualColumn (Line, this.location.Column);
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/CaretMoveActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/CaretMoveActions.cs
index d83f492bb0..506afd90c8 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/CaretMoveActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/CaretMoveActions.cs
@@ -61,15 +61,15 @@ namespace Mono.TextEditor
return;
}
- if (data.Caret.Column > 0) {
- if (data.Caret.Column > line.EditableLength) {
- data.Caret.Column = line.EditableLength;
+ if (data.Caret.Column > DocumentLocation.MinColumn) {
+ if (data.Caret.Column > line.EditableLength + 1) {
+ data.Caret.Column = line.EditableLength + 1;
} else {
data.Caret.Column--;
}
- } else if (data.Caret.Line > 0) {
+ } else if (data.Caret.Line > DocumentLocation.MinLine) {
LineSegment prevLine = data.Document.GetLine (data.Caret.Line - 1);
- data.Caret.Location = new DocumentLocation (data.Caret.Line - 1, prevLine.EditableLength);
+ data.Caret.Location = new DocumentLocation (data.Caret.Line - 1, prevLine.EditableLength + 1);
}
}
@@ -104,20 +104,20 @@ namespace Mono.TextEditor
data.Caret.Location = data.Document.OffsetToLocation (segment.EndLine.Offset + segment.EndColumn);
return;
}
- if (data.Caret.Column < line.EditableLength || data.Caret.AllowCaretBehindLineEnd) {
- if (data.Caret.Column >= line.EditableLength) {
+ if (data.Caret.Column < line.EditableLength + 1 || data.Caret.AllowCaretBehindLineEnd) {
+ if (data.Caret.Column >= line.EditableLength + 1) {
int nextColumn = data.GetNextVirtualColumn (data.Caret.Line, data.Caret.Column);
if (data.Caret.Column != nextColumn) {
data.Caret.Column = nextColumn;
} else {
- data.Caret.Location = new DocumentLocation (data.Caret.Line + 1, 0);
+ data.Caret.Location = new DocumentLocation (data.Caret.Line + 1, DocumentLocation.MinColumn);
data.Caret.CheckCaretPosition ();
}
} else {
data.Caret.Column++;
}
} else if (data.Caret.Line + 1 < data.Document.LineCount) {
- data.Caret.Location = new DocumentLocation (data.Caret.Line + 1, 0);
+ data.Caret.Location = new DocumentLocation (data.Caret.Line + 1, DocumentLocation.MinColumn);
}
}
@@ -140,13 +140,14 @@ namespace Mono.TextEditor
int col = data.MainSelection.Anchor > data.MainSelection.Lead ? data.MainSelection.Lead.Column : data.MainSelection.Anchor.Column;
int line = data.MainSelection.MinLine - 1;
data.ClearSelection ();
- data.Caret.Location = (line >= 0) ? new DocumentLocation (line, col) : new DocumentLocation (0, 0);
+ data.Caret.Location = (line >= DocumentLocation.MinLine) ? new DocumentLocation (line, col) : new DocumentLocation (DocumentLocation.MinLine, DocumentLocation.MinColumn);
data.Caret.SetToDesiredColumn (desiredColumn);
return;
}
- if (data.Caret.Line > 0) {
- int line = data.Document.VisualToLogicalLine (data.Document.LogicalToVisualLine (data.Caret.Line) - 1);
+ if (data.Caret.Line > DocumentLocation.MinLine) {
+ int visualLine = data.Document.LogicalToVisualLine (data.Caret.Line);
+ int line = data.Document.VisualToLogicalLine (visualLine - 1);
int offset = data.Document.LocationToOffset (line, data.Caret.Column);
data.Caret.Offset = MoveCaretOutOfFolding (data, offset);
data.Caret.SetToDesiredColumn (desiredColumn);
@@ -183,7 +184,7 @@ namespace Mono.TextEditor
return;
}
- if (data.Caret.Line < data.Document.LineCount - 1) {
+ if (data.Caret.Line < data.Document.LineCount) {
int line = data.Document.VisualToLogicalLine (data.Document.LogicalToVisualLine (data.Caret.Line) + 1);
int offset = data.Document.LocationToOffset (line, data.Caret.Column);
data.Caret.SetToOffsetWithDesiredColumn (MoveCaretOutOfFolding (data, offset));
@@ -197,26 +198,28 @@ namespace Mono.TextEditor
int result;
for (result = 0; result < line.EditableLength; result++)
if (!Char.IsWhiteSpace (document.GetCharAt (line.Offset + result)))
- return result;
- return result;
+ return result + 1;
+ return result + 1;
}
static void InternalCaretMoveHome (TextEditorData data, bool firstNonWhitespace, bool hop)
{
if (!data.Caret.PreserveSelection)
data.ClearSelection ();
- DocumentLocation newLocation = data.Caret.Location;
+ DocumentLocation newLocation = data.Caret.Location;
+
LineSegment line = data.Document.GetLine (data.Caret.Line);
- if (firstNonWhitespace) {
+ if (firstNonWhitespace) {
+
int homeMark = GetHomeMark (data.Document, line);
if (hop) {
- newLocation.Column = data.Caret.Column == homeMark ? 0 : homeMark;
+ newLocation.Column = data.Caret.Column == homeMark ? DocumentLocation.MinColumn : homeMark;
} else {
newLocation.Column = homeMark;
}
} else {
- newLocation.Column = 0;
+ newLocation.Column = DocumentLocation.MinColumn;
}
// handle folding
@@ -230,9 +233,12 @@ namespace Mono.TextEditor
}
if (segment != null)
newLocation = data.Document.OffsetToLocation (segment.StartLine.Offset);
-
- if (newLocation != data.Caret.Location)
- data.Caret.Location = newLocation;
+
+
+ if (newLocation != data.Caret.Location)
+
+ data.Caret.Location = newLocation;
+
}
public static void LineHome (TextEditorData data)
@@ -255,8 +261,9 @@ namespace Mono.TextEditor
if (!data.Caret.PreserveSelection)
data.ClearSelection ();
DocumentLocation newLocation = data.Caret.Location;
- LineSegment line = data.Document.GetLine (data.Caret.Line);
- newLocation.Column = line.EditableLength;
+ LineSegment line = data.Document.GetLine (data.Caret.Line);
+
+ newLocation.Column = line.EditableLength + 1;
// handle folding
IEnumerable<FoldSegment> foldings = data.Document.GetStartFoldings (line);
@@ -269,23 +276,22 @@ namespace Mono.TextEditor
}
if (segment != null)
newLocation = data.Document.OffsetToLocation (segment.EndLine.Offset + segment.EndColumn);
- if (newLocation != data.Caret.Location) {
+ if (newLocation != data.Caret.Location)
data.Caret.Location = newLocation;
- }
if (data.Caret.AllowCaretBehindLineEnd) {
int nextColumn = data.GetNextVirtualColumn (data.Caret.Line, data.Caret.Column);
if (nextColumn != data.Caret.Column)
data.Caret.Column = nextColumn;
}
-
+
}
public static void ToDocumentStart (TextEditorData data)
{
if (!data.Caret.PreserveSelection)
data.ClearSelection ();
- data.Caret.Location = new DocumentLocation (0, 0);
+ data.Caret.Location = new DocumentLocation (DocumentLocation.MinLine, DocumentLocation.MinColumn);
}
public static void ToDocumentEnd (TextEditorData data)
@@ -302,7 +308,7 @@ namespace Mono.TextEditor
int pageLines = (int)((data.VAdjustment.PageSize + ((int)data.VAdjustment.Value % LineHeight)) / LineHeight);
int visualLine = data.Document.LogicalToVisualLine (data.Caret.Line);
visualLine -= pageLines;
- int line = System.Math.Max (data.Document.VisualToLogicalLine (visualLine), 0);
+ int line = System.Math.Max (data.Document.VisualToLogicalLine (visualLine), DocumentLocation.MinLine);
int offset = data.Document.LocationToOffset (line, data.Caret.Column);
ScrollActions.PageUp (data);
data.Caret.Offset = MoveCaretOutOfFolding (data, offset);
@@ -314,7 +320,7 @@ namespace Mono.TextEditor
int visualLine = data.Document.LogicalToVisualLine (data.Caret.Line);
visualLine += pageLines;
- int line = System.Math.Min (data.Document.VisualToLogicalLine (visualLine), data.Document.LineCount - 1);
+ int line = System.Math.Min (data.Document.VisualToLogicalLine (visualLine), data.Document.LineCount);
int offset = data.Document.LocationToOffset (line, data.Caret.Column);
ScrollActions.PageDown (data);
data.Caret.Offset = MoveCaretOutOfFolding (data, offset);
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/ClipboardActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/ClipboardActions.cs
index 505cdce0f5..7a1222c195 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/ClipboardActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/ClipboardActions.cs
@@ -259,7 +259,7 @@ namespace Mono.TextEditor
LineSegment line = data.Document.GetLineByOffset (segment.Offset);
var spanStack = line.StartSpan.Clone ();
SyntaxModeService.ScanSpans (data.Document, this.mode, this.mode, spanStack, line.Offset, segment.Offset);
- this.copiedDocument.GetLine (0).StartSpan = spanStack;
+ this.copiedDocument.GetLine (DocumentLocation.MinLine).StartSpan = spanStack;
break;
case SelectionMode.Block:
isBlockMode = true;
@@ -285,7 +285,7 @@ namespace Mono.TextEditor
line = data.Document.GetLine (selection.MinLine);
spanStack = line.StartSpan.Clone ();
SyntaxModeService.ScanSpans (data.Document, this.mode, this.mode, spanStack, line.Offset, line.Offset + startCol);
- this.copiedDocument.GetLine (0).StartSpan = spanStack;
+ this.copiedDocument.GetLine (DocumentLocation.MinLine).StartSpan = spanStack;
break;
}
} else {
@@ -300,7 +300,7 @@ namespace Mono.TextEditor
if (data.IsSomethingSelected) {
selection = data.MainSelection;
} else {
- selection = new Selection (new DocumentLocation (data.Caret.Line, 0), new DocumentLocation (data.Caret.Line, data.Document.GetLine (data.Caret.Line).Length));
+ selection = new Selection (new DocumentLocation (data.Caret.Line, DocumentLocation.MinColumn), new DocumentLocation (data.Caret.Line, data.Document.GetLine (data.Caret.Line).Length));
}
CopyData (data, selection);
@@ -363,7 +363,7 @@ namespace Mono.TextEditor
curLine = data.Document.GetLine (lineNr + i);
if (lines[i].Length > 0) {
lineCol = curLine.GetLogicalColumn (data, visCol);
- if (curLine.EditableLength < lineCol) {
+ if (curLine.EditableLength + 1 < lineCol) {
result += lineCol - curLine.EditableLength;
data.Insert (curLine.Offset + curLine.EditableLength, new string (' ', lineCol - curLine.EditableLength));
}
@@ -464,7 +464,7 @@ namespace Mono.TextEditor
if (!data.CanEditSelection)
return;
LineSegment line = data.Document.GetLine (data.Caret.Line);
- if (data.Caret.Column > line.EditableLength) {
+ if (data.Caret.Column > line.EditableLength + 1) {
string text = data.GetVirtualSpaces (data.Caret.Line, data.Caret.Column);
int offset = data.Caret.Offset;
int textLength = data.Insert (offset, text);
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
index 5d970be13d..a8a5d9e34a 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/DefaultEditActions.cs
@@ -120,9 +120,9 @@ namespace Mono.TextEditor
if (data.IsSomethingSelected)
SelectLineBlock (data, endLineNr, startLineNr);
- if (data.Caret.Column != 0) {
+ if (data.Caret.Column != DocumentLocation.MinColumn) {
data.Caret.PreserveSelection = true;
- data.Caret.Column = System.Math.Max (0, data.Caret.Column - last);
+ data.Caret.Column = System.Math.Max (DocumentLocation.MinColumn, data.Caret.Column - last);
data.Caret.PreserveSelection = false;
}
@@ -134,11 +134,11 @@ namespace Mono.TextEditor
static void SelectLineBlock (TextEditorData data, int endLineNr, int startLineNr)
{
if (startLineNr == endLineNr) {
- data.MainSelection = new Selection (startLineNr, 0, startLineNr + 1, 0);
+ data.MainSelection = new Selection (startLineNr, DocumentLocation.MinColumn, startLineNr + 1, DocumentLocation.MinColumn);
return;
}
LineSegment endLine = data.Document.GetLine (endLineNr);
- data.MainSelection = new Selection (startLineNr, 0, endLineNr, endLine.Length);
+ data.MainSelection = new Selection (startLineNr, DocumentLocation.MinColumn, endLineNr, endLine.Length + 1);
}
public static void RemoveTab (TextEditorData data)
@@ -179,12 +179,12 @@ namespace Mono.TextEditor
end = data.MainSelection.Anchor;
}
startLineNr = start.Line;
- endLineNr = end.Column == 0 ? end.Line - 1 : end.Line;
+ endLineNr = end.Column == DocumentLocation.MinColumn ? end.Line - 1 : end.Line;
} else {
startLineNr = endLineNr = data.Caret.Line;
}
- if (endLineNr < 0)
+ if (endLineNr < DocumentLocation.MinLine)
endLineNr = data.Document.LineCount;
}
@@ -200,7 +200,7 @@ namespace Mono.TextEditor
if (data.IsSomethingSelected)
SelectLineBlock (data, endLineNr, startLineNr);
- if (data.Caret.Column != 0) {
+ if (data.Caret.Column != DocumentLocation.MinColumn) {
data.Caret.PreserveSelection = true;
data.Caret.Column++;
data.Caret.PreserveSelection = false;
@@ -260,7 +260,7 @@ namespace Mono.TextEditor
if (!data.CanEditSelection)
return;
LineSegment line = data.Document.GetLine (data.Caret.Line);
- data.Caret.Column = line.EditableLength;
+ data.Caret.Column = line.EditableLength + 1;
InsertNewLine (data);
}
@@ -417,7 +417,7 @@ namespace Mono.TextEditor
}
int offset = data.Caret.Offset;
- if (data.Caret.Column >= line.EditableLength) {
+ if (data.Caret.Column >= line.EditableLength + 1) {
offset = line.Offset + line.EditableLength - 1;
transposeOffset = offset - 1;
// case one char in line:
@@ -436,7 +436,7 @@ namespace Mono.TextEditor
ch = data.Document.GetCharAt (offset);
data.Replace (offset, 1, data.Document.GetCharAt (transposeOffset).ToString ());
data.Replace (transposeOffset, 1, ch.ToString ());
- if (data.Caret.Column < line.EditableLength)
+ if (data.Caret.Column < line.EditableLength + 1)
data.Caret.Offset = offset + 1;
}
/// <summary>
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/DeleteActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/DeleteActions.cs
index 0d296e1600..08b91eb1ed 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/DeleteActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/DeleteActions.cs
@@ -107,12 +107,13 @@ namespace Mono.TextEditor
return;
LineSegment line = data.Document.GetLine (data.Caret.Line);
data.EnsureCaretIsNotVirtual ();
- if (data.Caret.Column == line.EditableLength) {
+ int physColumn = data.Caret.Column - 1;
+ if (physColumn == line.EditableLength) {
// Nothing after the cursor, delete the end-of-line sequence
- data.Remove (line.Offset + data.Caret.Column, line.Length - data.Caret.Column);
+ data.Remove (line.Offset + physColumn, line.Length - physColumn);
} else {
// Delete from cursor position to the end of the line
- data.Remove (line.Offset + data.Caret.Column, line.EditableLength - data.Caret.Column);
+ data.Remove (line.Offset + physColumn, line.EditableLength - physColumn);
}
data.Document.CommitLineUpdate (data.Caret.Line);
}
@@ -146,11 +147,11 @@ namespace Mono.TextEditor
if (data.Caret.Offset == 0)
return;
LineSegment line = data.Document.GetLine (data.Caret.Line);
- if (data.Caret.Column > line.EditableLength) {
- data.Caret.Column = line.EditableLength;
+ if (data.Caret.Column > line.EditableLength + 1) {
+ data.Caret.Column = line.EditableLength + 1;
} else if (data.Caret.Offset == line.Offset) {
LineSegment lineAbove = data.Document.GetLine (data.Caret.Line - 1);
- data.Caret.Location = new DocumentLocation (data.Caret.Line - 1, lineAbove.EditableLength);
+ data.Caret.Location = new DocumentLocation (data.Caret.Line - 1, lineAbove.EditableLength + 1);
data.Remove (lineAbove.EndOffset - lineAbove.DelimiterLength, lineAbove.DelimiterLength);
} else {
removeCharBeforeCaret (data);
@@ -177,7 +178,7 @@ namespace Mono.TextEditor
if (data.Caret.Offset >= data.Document.Length)
return;
LineSegment line = data.Document.GetLine (data.Caret.Line);
- if (data.Caret.Column == line.EditableLength) {
+ if (data.Caret.Column == line.EditableLength + 1) {
if (data.Caret.Line < data.Document.LineCount) {
data.Remove (line.EndOffset - line.DelimiterLength, line.DelimiterLength);
if (line.EndOffset == data.Document.Length)
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document.cs
index 0766a4822e..05dde92024 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document.cs
@@ -26,8 +26,8 @@
//
using System;
-using System.Collections.Generic;
-using System.Diagnostics;
+using System.Collections.Generic;
+using System.Diagnostics;
using Mono.TextEditor.Highlighting;
using Mono.TextEditor.Utils;
using System.Linq;
@@ -83,10 +83,10 @@ namespace Mono.TextEditor
set;
}
- protected Document (IBuffer buffer, ILineSplitter splitter)
- {
- this.buffer = buffer;
- this.splitter = splitter;
+ protected Document (IBuffer buffer, ILineSplitter splitter)
+ {
+ this.buffer = buffer;
+ this.splitter = splitter;
splitter.LineChanged += SplitterLineSegmentTreeLineChanged;
splitter.LineRemoved += HandleSplitterLineSegmentTreeLineRemoved;
TextReplacing += UpdateFoldSegmentsOnReplace;
@@ -101,13 +101,13 @@ namespace Mono.TextEditor
Text = text;
}
- public static Document CreateImmutableDocument (string text)
- {
- return new Document(new StringBuffer(text), new PrimitiveLineSplitter()) {
- SurpressHighlightUpdate = true,
- Text = text,
- ReadOnly = true
- };
+ public static Document CreateImmutableDocument (string text)
+ {
+ return new Document(new StringBuffer(text), new PrimitiveLineSplitter()) {
+ SurpressHighlightUpdate = true,
+ Text = text,
+ ReadOnly = true
+ };
}
~Document ()
@@ -132,8 +132,8 @@ namespace Mono.TextEditor
get {
return this.buffer.Length;
}
- }
-
+ }
+
public bool SurpressHighlightUpdate { get; set; }
public string Text {
@@ -146,7 +146,7 @@ namespace Mono.TextEditor
ReplaceEventArgs args = new ReplaceEventArgs (0, Length, value);
this.OnTextReplacing (args);
this.buffer.Text = value;
- splitter.Initalize (value);
+ splitter.Initalize (value);
UpdateHighlighting ();
this.OnTextReplaced (args);
this.OnTextSet (EventArgs.Empty);
@@ -337,20 +337,20 @@ namespace Mono.TextEditor
}
}
- public IEnumerable<LineSegment> GetLinesBetween (int startLine, int endLine)
- {
- return splitter.GetLinesBetween (startLine, endLine);
- }
-
- public IEnumerable<LineSegment> GetLinesStartingAt (int startLine)
- {
- return splitter.GetLinesStartingAt (startLine);
- }
-
- public IEnumerable<LineSegment> GetLinesReverseStartingAt (int startLine)
- {
- return splitter.GetLinesReverseStartingAt (startLine);
- }
+ public IEnumerable<LineSegment> GetLinesBetween (int startLine, int endLine)
+ {
+ return splitter.GetLinesBetween (startLine, endLine);
+ }
+
+ public IEnumerable<LineSegment> GetLinesStartingAt (int startLine)
+ {
+ return splitter.GetLinesStartingAt (startLine);
+ }
+
+ public IEnumerable<LineSegment> GetLinesReverseStartingAt (int startLine)
+ {
+ return splitter.GetLinesReverseStartingAt (startLine);
+ }
public int LocationToOffset (int line, int column)
{
@@ -359,19 +359,20 @@ namespace Mono.TextEditor
public int LocationToOffset (DocumentLocation location)
{
- if (location.Line >= this.splitter.Count)
- return -1;
+// if (location.Column < DocumentLocation.MinColumn)
+// throw new ArgumentException ("column < MinColumn");
+ // line is checked by Getline
LineSegment line = GetLine (location.Line);
- return System.Math.Min (Length, line.Offset + System.Math.Min (line.EditableLength, location.Column));
+ return System.Math.Min (Length, line.Offset + System.Math.Max (0, System.Math.Min (line.EditableLength, location.Column - 1)));
}
public DocumentLocation OffsetToLocation (int offset)
{
int lineNr = splitter.OffsetToLineNumber (offset);
- if (lineNr < 0)
+ if (lineNr < DocumentLocation.MinLine)
return DocumentLocation.Empty;
LineSegment line = GetLine (lineNr);
- return new DocumentLocation (lineNr, System.Math.Min (line.Length, offset - line.Offset));
+ return new DocumentLocation (lineNr, System.Math.Min (line.Length, offset - line.Offset) + 1);
}
public string GetLineIndent (int lineNumber)
@@ -388,6 +389,9 @@ namespace Mono.TextEditor
public LineSegment GetLine (int lineNumber)
{
+ if (lineNumber < DocumentLocation.MinLine)
+ return null;
+
return splitter.Get (lineNumber);
}
@@ -972,7 +976,7 @@ namespace Mono.TextEditor
public int LogicalToVisualLine (Document doc, int logicalLine)
{
int result = logicalLine;
- LineSegment line = doc.GetLine (result) ?? doc.GetLine (doc.LineCount - 1);
+ LineSegment line = doc.GetLine (result) ?? doc.GetLine (doc.LineCount);
foreach (FoldSegment segment in Traverse (x => !(x.IsFolded && x.StartLine.Offset < line.Offset))) {
if (segment.IsFolded && segment.StartLine.Offset < line.Offset) {
result -= doc.GetLineCount (segment);
@@ -1353,8 +1357,8 @@ namespace Mono.TextEditor
public int VisualToLogicalLine (int visualLineNumber)
{
- if (visualLineNumber <= 0)
- return 0;
+ if (visualLineNumber <= DocumentLocation.MinLine)
+ return DocumentLocation.MinLine;
return this.FoldSegmentTree.VisualToLogicalLine (this, visualLineNumber);
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/DocumentLocation.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/DocumentLocation.cs
index 9231e28362..0c16afae77 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/DocumentLocation.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/DocumentLocation.cs
@@ -31,14 +31,18 @@ namespace Mono.TextEditor
{
public struct DocumentLocation
{
- public static readonly DocumentLocation Empty = new DocumentLocation (-1, -1);
+ public static readonly DocumentLocation Empty = new DocumentLocation (0, 0);
+
+ public const int MinLine = 1;
+ public const int MinColumn = 1;
+
public int Line { get; set; }
public int Column { get; set; }
public bool IsEmpty {
get {
- return Line < 0 && Column < 0;
+ return Line < MinLine && Column < MinColumn;
}
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs
index 363efe450f..179fbbdf88 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/EditMode.cs
@@ -35,8 +35,8 @@ namespace Mono.TextEditor
{
//NOTE: the behaviour of this class is actually stateless; these variables are used to make the API
// friendlier for subclassers of this class
- TextEditorData textEditorData;
- TextEditor editor;
+ protected TextEditorData textEditorData;
+ protected TextEditor editor;
// string status;
internal void InternalHandleKeypress (TextEditor editor, TextEditorData data, Gdk.Key key,
@@ -118,8 +118,8 @@ namespace Mono.TextEditor
char ch = (char)unicodeKey;
if (!char.IsControl (ch) && textEditorData.CanEdit (Caret.Line)) {
LineSegment line = Document.GetLine (Caret.Line);
- if (Caret.IsInInsertMode || Caret.Column >= line.EditableLength) {
- string text = Caret.Column > line.EditableLength ? textEditorData.GetVirtualSpaces (Caret.Line, Caret.Column) + ch.ToString () : ch.ToString ();
+ if (Caret.IsInInsertMode || Caret.Column >= line.EditableLength + 1) {
+ string text = Caret.Column > line.EditableLength + 1 ? textEditorData.GetVirtualSpaces (Caret.Line, Caret.Column) + ch.ToString () : ch.ToString ();
if (textEditorData.IsSomethingSelected && textEditorData.MainSelection.SelectionMode == SelectionMode.Block) {
int length = 0;
for (int lineNumber = textEditorData.MainSelection.MinLine; lineNumber <= textEditorData.MainSelection.MaxLine; lineNumber++) {
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
index 23c122ca56..2360f3dd25 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/GutterMargin.cs
@@ -89,7 +89,7 @@ namespace Mono.TextEditor
}
}
- DocumentLocation anchorLocation = DocumentLocation.Empty;
+ DocumentLocation anchorLocation = new DocumentLocation (DocumentLocation.MinLine, DocumentLocation.MinColumn);
internal protected override void MousePressed (MarginMouseEventArgs args)
{
base.MousePressed (args);
@@ -100,7 +100,7 @@ namespace Mono.TextEditor
int lineNumber = args.LineNumber;
bool extendSelection = (args.ModifierState & Gdk.ModifierType.ShiftMask) == Gdk.ModifierType.ShiftMask;
if (lineNumber < editor.Document.LineCount) {
- DocumentLocation loc = new DocumentLocation (lineNumber, 0);
+ DocumentLocation loc = new DocumentLocation (lineNumber, DocumentLocation.MinColumn);
LineSegment line = args.LineSegment;
if (args.Type == EventType.TwoButtonPress) {
if (line != null)
@@ -151,9 +151,9 @@ namespace Mono.TextEditor
if (args.Button == 1) {
// DocumentLocation loc = editor.Document.LogicalToVisualLocation (editor.GetTextEditorData (), editor.Caret.Location);
- int lineNumber = args.LineNumber != -1 ? args.LineNumber : editor.Document.LineCount - 1;
+ int lineNumber = args.LineNumber >= DocumentLocation.MinLine ? args.LineNumber : editor.Document.LineCount;
editor.Caret.PreserveSelection = true;
- editor.Caret.Location = new DocumentLocation (lineNumber, 0);
+ editor.Caret.Location = new DocumentLocation (lineNumber, DocumentLocation.MinColumn);
editor.MainSelection = new Selection (anchorLocation, editor.Caret.Location);
editor.Caret.PreserveSelection = false;
}
@@ -191,7 +191,7 @@ namespace Mono.TextEditor
cr.Fill ();
if (line < editor.Document.LineCount) {
- layout.SetText ((line + 1).ToString ());
+ layout.SetText (line.ToString ());
cr.Save ();
cr.Translate (x + (int)Width, y);
cr.Color = editor.Caret.Line == line ? lineNumberHighlightGC : lineNumberGC;
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/IconMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/IconMargin.cs
index a855bbce41..c38168fa8b 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/IconMargin.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/IconMargin.cs
@@ -105,7 +105,7 @@ namespace Mono.TextEditor
ctx.Color = separatorColor;
ctx.Stroke ();
- if (line < editor.Document.LineCount) {
+ if (line <= editor.Document.LineCount) {
LineSegment lineSegment = editor.Document.GetLine (line);
foreach (TextMarker marker in lineSegment.Markers) {
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/InsertionCursorEditMode.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/InsertionCursorEditMode.cs
index f54ced588b..6327990c88 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/InsertionCursorEditMode.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/InsertionCursorEditMode.cs
@@ -180,14 +180,14 @@ namespace Mono.TextEditor
if (CurIndex > 0)
CurIndex--;
DocumentLocation loc = insertionPoints[CurIndex].Location;
- editor.CenterTo (loc.Line - 1, 0);
+ editor.CenterTo (loc.Line - 1, DocumentLocation.MinColumn);
editor.QueueDraw ();
break;
case Gdk.Key.Down:
if (CurIndex < insertionPoints.Count - 1)
CurIndex++;
loc = insertionPoints[CurIndex].Location;
- editor.CenterTo (loc.Line + 1, 0);
+ editor.CenterTo (loc.Line + 1, DocumentLocation.MinColumn);
editor.QueueDraw ();
break;
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSegment.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSegment.cs
index 31c0937d2e..ae8a781de6 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSegment.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSegment.cs
@@ -180,7 +180,7 @@ namespace Mono.TextEditor
public int GetLogicalColumn (TextEditorData editor, int visualColumn)
{
- int curVisualColumn = 0;
+ int curVisualColumn = 1;
int offset = Offset;
int max = offset + EditableLength;
for (int i = offset; i < max; i++) {
@@ -190,16 +190,16 @@ namespace Mono.TextEditor
curVisualColumn++;
}
if (curVisualColumn > visualColumn)
- return i - offset;
+ return i - offset + 1;
}
- return EditableLength + (visualColumn - curVisualColumn);
+ return EditableLength + (visualColumn - curVisualColumn) + 1;
}
public int GetVisualColumn (TextEditorData editor, int logicalColumn)
{
- int result = 0;
+ int result = 1;
int offset = Offset;
- for (int i = 0; i < logicalColumn; i++) {
+ for (int i = 0; i < logicalColumn - 1; i++) {
if (i < EditableLength && editor.Document.GetCharAt (offset + i) == '\t') {
result = TextViewMargin.GetNextTabstop (editor, result);
} else {
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
index 96c25b4646..56812a21ca 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/LineSplitter.cs
@@ -60,7 +60,7 @@ namespace Mono.TextEditor
public IEnumerable<LineSegment> GetLinesBetween (int startLine, int endLine)
{
- var startNode = GetNode (startLine);
+ var startNode = GetNode (startLine - 1);
if (startNode == null)
yield break;
var iter = startNode.Iter;
@@ -72,7 +72,7 @@ namespace Mono.TextEditor
public IEnumerable<LineSegment> GetLinesStartingAt (int startLine)
{
- var startNode = GetNode (startLine);
+ var startNode = GetNode (startLine - 1);
if (startNode == null)
yield break;
var iter = startNode.Iter;
@@ -94,7 +94,7 @@ namespace Mono.TextEditor
public LineSegment Get (int number)
{
- return GetNode (number);
+ return GetNode (number - 1);
}
public LineSegment GetLineByOffset (int offset)
@@ -406,7 +406,7 @@ namespace Mono.TextEditor
{
var node = GetTreeNodeAtOffset (offset);
if (node == null)
- return -1;
+ return 0;
int result = node.Left != null ? node.Left.Value.Count : 0;
while (node.Parent != null) {
if (node == node.Parent.Right) {
@@ -416,7 +416,7 @@ namespace Mono.TextEditor
}
node = node.Parent;
}
- return result;
+ return result + 1;
}
public void RemoveLine (TreeNode line)
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Margin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Margin.cs
index bfcdd4cab1..8e69c1fef5 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Margin.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Margin.cs
@@ -158,7 +158,7 @@ namespace Mono.TextEditor
public LineSegment LineSegment {
get {
if (line == null) {
- if (LineNumber == -1)
+ if (LineNumber < DocumentLocation.MinLine)
return null;
line = Editor.Document.GetLine (lineNumber);
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/PrimitiveLineSplitter.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/PrimitiveLineSplitter.cs
index ddbd8b51c5..f613a43f08 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/PrimitiveLineSplitter.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/PrimitiveLineSplitter.cs
@@ -27,7 +27,7 @@ namespace Mono.TextEditor
}
public IEnumerable<LineSegment> Lines {
- get { return GetLinesStartingAt (0); }
+ get { return GetLinesStartingAt (DocumentLocation.MinLine); }
}
public void Initalize (string text)
@@ -44,6 +44,7 @@ namespace Mono.TextEditor
public LineSegment Get (int number)
{
+ number--;
if (number < 0)
return null;
int startOffset = number > 0 ? delimiters[number - 1].EndOffset : 0;
@@ -69,7 +70,7 @@ namespace Mono.TextEditor
for (int i = 0; i < delimiters.Count; i++) {
var delimiter = delimiters[i];
if (offset < delimiter.Offset)
- return i;
+ return i + 1;
}
return -1;
}
@@ -97,13 +98,13 @@ namespace Mono.TextEditor
public IEnumerable<LineSegment> GetLinesStartingAt (int startLine)
{
- for (int i = startLine; i < Count; i++)
+ for (int i = startLine; i <= Count; i++)
yield return Get (i);
}
public IEnumerable<LineSegment> GetLinesReverseStartingAt (int startLine)
{
- for (int i = Count - 1; i-- > 0;)
+ for (int i = startLine; i-- > DocumentLocation.MinLine;)
yield return Get (i);
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Selection.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Selection.cs
index f8dedd9c45..22a360e47c 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Selection.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Selection.cs
@@ -80,6 +80,10 @@ namespace Mono.TextEditor
public Selection (DocumentLocation anchor, DocumentLocation lead, SelectionMode selectionMode)
{
+ if (anchor.Line < DocumentLocation.MinLine || anchor.Column < DocumentLocation.MinColumn)
+ throw new ArgumentException ("anchor");
+ if (lead.Line < DocumentLocation.MinLine || lead.Column < DocumentLocation.MinColumn)
+ throw new ArgumentException ("lead");
this.Anchor = anchor;
this.Lead = lead;
this.SelectionMode = selectionMode;
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/SelectionActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/SelectionActions.cs
index c4e9fb95d6..cf1b2a636c 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/SelectionActions.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/SelectionActions.cs
@@ -105,7 +105,7 @@ namespace Mono.TextEditor
{
data.Caret.PreserveSelection = true;
if (!data.IsSomethingSelected) {
- data.MainSelection = new Selection (new DocumentLocation (data.Caret.Line, 0), new DocumentLocation (data.Caret.Line, 0));
+ data.MainSelection = new Selection (new DocumentLocation (data.Caret.Line, DocumentLocation.MinColumn), new DocumentLocation (data.Caret.Line, DocumentLocation.MinColumn));
}
}
@@ -129,7 +129,6 @@ namespace Mono.TextEditor
int toOffset = (toLine < fromLine)? toSegment.Offset: toSegment.EndOffset;
data.ExtendSelectionTo (toOffset);
}
-
data.Caret.PreserveSelection = false;
}
@@ -137,7 +136,7 @@ namespace Mono.TextEditor
{
data.Caret.PreserveSelection = true;
CaretMoveActions.ToDocumentEnd (data);
- data.MainSelection = new Selection (new DocumentLocation (0, 0), data.Caret.Location);
+ data.MainSelection = new Selection (new DocumentLocation (DocumentLocation.MinLine, DocumentLocation.MinColumn), data.Caret.Location);
data.Caret.PreserveSelection = false;
}
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditor.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
index e3a197544e..4854710ded 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditor.cs
@@ -1,4 +1,3 @@
-
//
// TextEditor.cs
//
@@ -693,7 +692,7 @@ namespace Mono.TextEditor
start = 0;
double visualStart = -this.textEditorData.VAdjustment.Value + LineToY (start);
if (end < 0)
- end = Document.LineCount - 1;
+ end = Document.LineCount;
double visualEnd = -this.textEditorData.VAdjustment.Value + LineToY (end) + GetLineHeight (end);
QueueDrawArea ((int)margin.XOffset, (int)visualStart, GetMarginWidth (margin), (int)(visualEnd - visualStart));
}
@@ -707,7 +706,7 @@ namespace Mono.TextEditor
start = 0;
double visualStart = -this.textEditorData.VAdjustment.Value + Document.LogicalToVisualLine (start) * LineHeight;
if (end < 0)
- end = Document.LineCount - 1;
+ end = Document.LineCount;
double visualEnd = -this.textEditorData.VAdjustment.Value + Document.LogicalToVisualLine (end) * LineHeight + LineHeight;
QueueDrawArea (0, (int)visualStart, this.Allocation.Width, (int)(visualEnd - visualStart));
}
@@ -1315,7 +1314,7 @@ namespace Mono.TextEditor
internal void SetAdjustments (Gdk.Rectangle allocation)
{
if (this.textEditorData.VAdjustment != null) {
- double maxY = LineToY (Document.LineCount - 1);
+ double maxY = Document.LineCount > 1 ? LineToY (Document.LineCount) : LineHeight;
if (maxY > allocation.Height)
maxY += 5 * this.LineHeight;
@@ -1357,11 +1356,11 @@ namespace Mono.TextEditor
int logicalLineNumber = visualLineNumber;
LineSegment line = Document.GetLine (logicalLineNumber);
double lineHeight = GetLineHeight (line);
- int lastFold = -1;
+ int lastFold = 0;
foreach (FoldSegment fs in Document.GetStartFoldings (line).Where (fs => fs.IsFolded)) {
lastFold = System.Math.Max (fs.EndOffset, lastFold);
}
- if (lastFold > 0)
+ if (lastFold > DocumentLocation.MinLine)
visualLineNumber = Document.OffsetToLineNumber (lastFold);
foreach (Margin margin in this.margins) {
if (!margin.IsVisible)
@@ -1407,7 +1406,7 @@ namespace Mono.TextEditor
void UpdateAdjustments ()
{
- int lastVisibleLine = Document.LogicalToVisualLine (Document.LineCount - 1);
+ int lastVisibleLine = Document.LogicalToVisualLine (Document.LineCount);
if (oldRequest != lastVisibleLine) {
SetAdjustments (this.Allocation);
oldRequest = lastVisibleLine;
@@ -2199,8 +2198,11 @@ namespace Mono.TextEditor
void ShowTooltip (Gdk.ModifierType modifierState)
{
+ var loc = PointToLocation (mx, my);
+ if (loc.IsEmpty)
+ return;
ShowTooltip (modifierState,
- Document.LocationToOffset (PointToLocation (mx, my)),
+ Document.LocationToOffset (loc),
(int)mx,
(int)my);
}
@@ -2606,7 +2608,7 @@ namespace Mono.TextEditor
{
if (view.isDisposed)
return;
- line = System.Math.Min (line, view.Document.LineCount - 1);
+ line = System.Math.Min (line, view.Document.LineCount);
view.Caret.AutoScrollToCaret = false;
try {
view.Caret.Location = new DocumentLocation (line, column);
@@ -2632,6 +2634,11 @@ namespace Mono.TextEditor
public void SetCaretTo (int line, int column, bool highlight)
{
+ if (line < DocumentLocation.MinLine)
+ throw new ArgumentException ("line < MinLine");
+ if (column < DocumentLocation.MinColumn)
+ throw new ArgumentException ("column < MinColumn");
+
if (!IsRealized) {
SetCaret setCaret = new SetCaret (this, line, column, highlight);
SizeAllocated += setCaret.Run;
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
index 99cf0df372..08de1243e9 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
@@ -129,7 +129,7 @@ namespace Mono.TextEditor
if (Options.OverrideDocumentEolMarker)
return Options.DefaultEolMarker;
if (eol == null && Document.LineCount > 0) {
- LineSegment line = Document.GetLine (0);
+ LineSegment line = Document.GetLine (DocumentLocation.MinLine);
if (line.DelimiterLength > 0)
eol = Document.GetTextAt (line.EditableLength, line.DelimiterLength);
}
@@ -559,7 +559,7 @@ namespace Mono.TextEditor
int startLineNr = selection.MinLine;
int endLineNr = selection.MaxLine;
- bool skipEndLine = selection.Anchor < selection.Lead ? selection.Lead.Column == 0 : selection.Anchor.Column == 0;
+ bool skipEndLine = selection.Anchor < selection.Lead ? selection.Lead.Column == DocumentLocation.MinColumn : selection.Anchor.Column == DocumentLocation.MinColumn;
if (skipEndLine)
endLineNr--;
return document.GetLinesBetween (startLineNr, endLineNr);
@@ -841,7 +841,7 @@ namespace Mono.TextEditor
LineSegment line = doc.GetLine (lineNumber);
if (line == null)
return "";
- int count = column - line.EditableLength;
+ int count = column - 1 - line.EditableLength;
return new string (' ', System.Math.Max (0, count));
}
@@ -867,7 +867,7 @@ namespace Mono.TextEditor
if (line == null)
return 0;
- if (Caret.Column > line.EditableLength) {
+ if (Caret.Column > line.EditableLength + 1) {
string virtualSpace = GetVirtualSpaces (Caret.Line, Caret.Column);
if (!string.IsNullOrEmpty (virtualSpace))
Insert (Caret.Offset, virtualSpace);
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
index d935c83453..35c6307f66 100644
--- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
+++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs
@@ -34,7 +34,7 @@ using System.Runtime.InteropServices;
using Mono.TextEditor.Highlighting;
-using Gdk;
+using Gdk;
using Gtk;
using System.Timers;
@@ -1342,7 +1342,7 @@ namespace Mono.TextEditor
index += textEditor.preeditString.Length;
}
- if (Caret.Column > line.EditableLength) {
+ if (Caret.Column > line.EditableLength + 1) {
string virtualSpace = this.textEditor.GetTextEditorData ().GetVirtualSpaces (Caret.Line, Caret.Column);
LayoutWrapper wrapper = new LayoutWrapper (PangoUtil.CreateLayout (textEditor));
wrapper.LineChars = virtualSpace.ToCharArray ();
@@ -1493,6 +1493,8 @@ namespace Mono.TextEditor
if (args.Button == 1) {
VisualLocationTranslator trans = new VisualLocationTranslator (this);
clickLocation = trans.PointToLocation (args.X, args.Y);
+ if (clickLocation.IsEmpty)
+ return;
LineSegment line = Document.GetLine (clickLocation.Line);
bool isHandled = false;
if (line != null) {
@@ -1506,7 +1508,7 @@ namespace Mono.TextEditor
}
if (isHandled)
return;
- if (line != null && clickLocation.Column >= line.EditableLength && GetWidth (Document.GetTextAt (line) + "-") < args.X) {
+ if (line != null && clickLocation.Column >= line.EditableLength + 1 && GetWidth (Document.GetTextAt (line) + "-") < args.X) {
int nextColumn = this.textEditor.GetTextEditorData ().GetNextVirtualColumn (clickLocation.Line, clickLocation.Column);
clickLocation.Column = nextColumn;
}
@@ -1745,7 +1747,8 @@ namespace Mono.TextEditor
}
DocumentLocation loc = PointToLocation (args.X, args.Y);
-
+ if (loc.IsEmpty)
+ return;
LineSegment line = Document.GetLine (loc.Line);
LineSegment oldHoveredLine = HoveredLine;
HoveredLine = line;
@@ -1868,8 +1871,8 @@ namespace Mono.TextEditor
public static int GetNextTabstop (TextEditorData textEditor, int currentColumn)
{
int tabSize = textEditor != null && textEditor.Options != null ? textEditor.Options.TabSize : 4;
- int result = currentColumn + tabSize;
- return (result / tabSize) * tabSize;
+ int result = currentColumn - 1 + tabSize;
+ return 1 + (result / tabSize) * tabSize;
}
internal double rulerX = 0;
@@ -2208,7 +2211,7 @@ namespace Mono.TextEditor
public DocumentLocation PointToLocation (double xp, double yp)
{
- lineNumber = System.Math.Min (margin.YToLine (yp + margin.textEditor.VAdjustment.Value), margin.Document.LineCount - 1);
+ lineNumber = System.Math.Min (margin.YToLine (yp + margin.textEditor.VAdjustment.Value), margin.Document.LineCount);
line = lineNumber < margin.Document.LineCount ? margin.Document.GetLine (lineNumber) : null;
if (line == null)
return DocumentLocation.Empty;
@@ -2222,8 +2225,8 @@ namespace Mono.TextEditor
yp *= Pango.Scale.PangoScale;
yp = System.Math.Max (0, yp);
if (xp < 0)
- return new DocumentLocation (lineNumber, 0);
- int column = 0;
+ return new DocumentLocation (lineNumber, DocumentLocation.MinColumn);
+ int column = DocumentLocation.MinColumn;
SyntaxMode mode = margin.Document.SyntaxMode != null && margin.textEditor.Options.EnableSyntaxHighlighting ? margin.Document.SyntaxMode : SyntaxMode.Default;
IEnumerable<FoldSegment> foldings = margin.Document.GetStartFoldings (line);
bool done = false;
@@ -2450,7 +2453,7 @@ namespace Mono.TextEditor
return lineNumber;
}
}
- return Document.VisualToLogicalLine ((int)((yPos - delta) / LineHeight));
+ return Document.VisualToLogicalLine (1 + (int)((yPos - delta) / LineHeight));
}
public double LineToY (int logicalLine)
@@ -2465,7 +2468,7 @@ namespace Mono.TextEditor
delta += GetLineHeight (extendedTextMarkerLine) - LineHeight;
}
- int visualLine = Document.LogicalToVisualLine (logicalLine);
+ int visualLine = Document.LogicalToVisualLine (logicalLine) - 1;
return visualLine * LineHeight + delta;
}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.CodeGeneration/BaseRefactorer.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.CodeGeneration/BaseRefactorer.cs
index 99fc02a165..bc61e37bef 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.CodeGeneration/BaseRefactorer.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.CodeGeneration/BaseRefactorer.cs
@@ -1077,7 +1077,7 @@ namespace MonoDevelop.Projects.CodeGeneration
IMethod m = cls.Methods.Last ();
int pos;
- if (!m.BodyRegion.IsEmpty && m.BodyRegion.End.Line > 0) {
+ if (!m.BodyRegion.IsEmpty && m.BodyRegion.End.Line > 1) {
pos = buffer.GetPositionFromLineColumn (m.BodyRegion.End.Line, m.BodyRegion.End.Column);
pos = GetNextLine (buffer, pos);
pos = SkipBlankLine (buffer, pos);
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/BuildResult.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/BuildResult.cs
index 2ac9cc1bfd..07c5f16450 100644
--- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/BuildResult.cs
+++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/BuildResult.cs
@@ -222,9 +222,9 @@ namespace MonoDevelop.Projects
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
if (!string.IsNullOrEmpty (fileName)) {
sb.Append (fileName);
- if (line > 0) {
+ if (line > 1) {
sb.Append ('(').Append (line);
- if (column > 0)
+ if (column > 1)
sb.Append (',').Append (column);
sb.Append (')');
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PathBar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PathBar.cs
index 487788802b..08cc75e21e 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PathBar.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PathBar.cs
@@ -319,7 +319,6 @@ namespace MonoDevelop.Components
{
if (Path[hoverIndex].Position == EntryPosition.Left) {
int idx = leftPath.TakeWhile (p => p != Path[hoverIndex]).Count ();
- Console.WriteLine ("lidx={0}", idx);
if (idx >= 0) {
w = leftWidths[idx];
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs
index 57fdcfcc6d..ac859a8500 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/ExpansionObject.cs
@@ -106,7 +106,7 @@ namespace MonoDevelop.Ide.CodeTemplates
ITextEditorResolver textEditorResolver = CurrentContext.Document.GetContent <ITextEditorResolver> ();
if (textEditorResolver != null) {
- ResolveResult result = textEditorResolver.GetLanguageItem (CurrentContext.Document.Editor.Document.LocationToOffset (CurrentContext.InsertPosition.Line -1, CurrentContext.InsertPosition.Column - 1), var);
+ ResolveResult result = textEditorResolver.GetLanguageItem (CurrentContext.Document.Editor.Document.LocationToOffset (CurrentContext.InsertPosition.Line, CurrentContext.InsertPosition.Column), var);
if (result != null && (result.ResolvedType.ArrayDimensions > 0 || result.ResolvedType.FullName == DomReturnType.String.FullName))
return "Length";
}
@@ -184,7 +184,7 @@ namespace MonoDevelop.Ide.CodeTemplates
if (CurrentContext.ParsedDocument == null)
return fullTypeName;
- return CurrentContext.ParsedDocument.CompilationUnit.ShortenTypeName (new DomReturnType (fullTypeName), CurrentContext.InsertPosition.Line + 1, CurrentContext.InsertPosition.Column + 1).FullName;
+ return CurrentContext.ParsedDocument.CompilationUnit.ShortenTypeName (new DomReturnType (fullTypeName), CurrentContext.InsertPosition.Line, CurrentContext.InsertPosition.Column).FullName;
}
static Regex functionRegEx = new Regex ("([^(]*)\\(([^(]*)\\)", RegexOptions.Compiled);
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs
index 3869e343b8..f5fc0077c6 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/CustomStringTagProvider.cs
@@ -79,12 +79,12 @@ namespace MonoDevelop.Ide.Commands
case "CURLINE":
if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null)
- return wb.ActiveDocument.Editor.Caret.Line + 1;
+ return wb.ActiveDocument.Editor.Caret.Line;
return null;
case "CURCOLUMN":
if (wb.ActiveDocument != null && wb.ActiveDocument.Editor != null)
- return wb.ActiveDocument.Editor.Caret.Column + 1;
+ return wb.ActiveDocument.Editor.Caret.Column;
return null;
case "CUROFFSET":
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
index cb27b0c592..b5d2a776da 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs
@@ -279,7 +279,8 @@ namespace MonoDevelop.Ide.Commands
protected override void Run ()
{
- IdeApp.Workbench.ActiveDocument.Editor.SetCaretTo (IdeApp.Workbench.ActiveDocument.Editor.Caret.Line + 1, IdeApp.Workbench.ActiveDocument.Editor.Caret.Column + 1);
+ IdeApp.Workbench.ActiveDocument.Editor.SetCaretTo (IdeApp.Workbench.ActiveDocument.Editor.Caret.Line, IdeApp.Workbench.ActiveDocument.Editor.Caret.Column);
}
+
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs
index 45f5ea2875..939d20f03c 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs
@@ -357,7 +357,7 @@ namespace MonoDevelop.Ide.FindInFiles
if (searchResult == null)
return;
Document doc = GetDocument (searchResult);
- int lineNr = doc.OffsetToLineNumber (searchResult.Offset) + 1;
+ int lineNr = doc.OffsetToLineNumber (searchResult.Offset);
fileNameRenderer.Markup = MarkupText (System.IO.Path.GetFileName (searchResult.FileName) + ":" + lineNr, didRead);
}
@@ -569,7 +569,7 @@ namespace MonoDevelop.Ide.FindInFiles
Document doc = GetDocument (searchResult);
int lineNr = doc.OffsetToLineNumber (searchResult.Offset);
LineSegment line = doc.GetLine (lineNr);
- return new DocumentLocation (lineNr + 1, searchResult.Offset - line.Offset + 1);
+ return new DocumentLocation (lineNr, searchResult.Offset - line.Offset + 1);
}
public void OpenSelectedMatches ()
@@ -601,7 +601,7 @@ namespace MonoDevelop.Ide.FindInFiles
continue;
DocumentLocation loc = GetLocation (result);
Document doc = GetDocument (result);
- LineSegment line = doc.GetLine (loc.Line - 1);
+ LineSegment line = doc.GetLine (loc.Line);
sb.AppendFormat ("{0} ({1}, {2}):{3}", result.FileName, loc.Line, loc.Column, doc.GetTextAt (line.Offset, line.EditableLength));
sb.AppendLine ();
@@ -668,7 +668,7 @@ namespace MonoDevelop.Ide.FindInFiles
var searchResult = (SearchResult)store.GetValue (iter, SearchResultColumn);
Document doc = GetDocument (searchResult);
DocumentLocation location = doc.OffsetToLocation (searchResult.Offset);
- return new SearchTextFileNavigationPoint (searchResult.FileName, location.Line + 1, location.Column + 1);
+ return new SearchTextFileNavigationPoint (searchResult.FileName, location.Line, location.Column);
}
class SearchTextFileNavigationPoint : TextFileNavigationPoint
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HiddenTextEditorViewContent.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HiddenTextEditorViewContent.cs
index 295f53a630..e5660cffb4 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HiddenTextEditorViewContent.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/HiddenTextEditorViewContent.cs
@@ -104,14 +104,14 @@ namespace MonoDevelop.Ide.Gui
public int GetPositionFromLineColumn (int line, int column)
{
- return document.LocationToOffset (line - 1, column - 1);
+ return document.LocationToOffset (line, column);
}
public void GetLineColumnFromPosition (int position, out int line, out int column)
{
Mono.TextEditor.DocumentLocation loc = document.OffsetToLocation (position);
- line = loc.Line + 1;
- column = loc.Column + 1;
+ line = loc.Line;
+ column = loc.Column;
}
public string SelectedText { get { return ""; } set { } }
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs
index 7b80d259a2..3249610a71 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs
@@ -254,7 +254,7 @@ namespace MonoDevelop.Ide.Tasks
desc = tag.Key + ": " + desc;
}
- Task t = new Task (fileName, desc, tag.Region.Start.Column - 1, tag.Region.Start.Line,
+ Task t = new Task (fileName, desc, tag.Region.Start.Column, tag.Region.Start.Line,
TaskSeverity.Information, priorities[tag.Key], wob);
newTasks.Add (t);
}
@@ -479,12 +479,12 @@ namespace MonoDevelop.Ide.Tasks
if (doc != null && doc.HasProject && doc.Project is DotNetProject) {
string[] commentTags = doc.CommentTags;
if (commentTags != null && commentTags.Length == 1) {
- string line = doc.Editor.GetLineText (task.Line - 1);
+ string line = doc.Editor.GetLineText (task.Line);
int index = line.IndexOf (commentTags[0]);
if (index != -1) {
- doc.Editor.SetCaretTo (task.Line - 1, task.Column - 1);
+ doc.Editor.SetCaretTo (task.Line, task.Column);
line = line.Substring (0, index);
- var ls = doc.Editor.Document.GetLine (task.Line - 1);
+ var ls = doc.Editor.Document.GetLine (task.Line);
doc.Editor.Replace (ls.Offset, ls.EditableLength, line);
comments.Remove (task);
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs
index 552d2f1a0f..c74b2acae9 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/TaskStore.cs
@@ -83,7 +83,7 @@ namespace MonoDevelop.Ide.Tasks
return;
Task[] ctasks = GetFileTasks (args.TextFile.Name.FullPath);
foreach (Task task in ctasks) {
- if (task.Line - 1 > args.LineNumber || (task.Line - 1 == args.LineNumber && task.Column - 1 >= args.Column)) {
+ if (task.Line > args.LineNumber || (task.Line == args.LineNumber && task.Column >= args.Column)) {
if (task.SavedLine == -1)
task.SavedLine = task.Line;
task.Line += args.LineCount;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs
index 1fa7090dde..32539e5a82 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs
@@ -1628,14 +1628,14 @@ namespace MonoDevelop.Ide
public int GetPositionFromLineColumn (int line, int column)
{
- return data.Document.LocationToOffset (line - 1, column - 1);
+ return data.Document.LocationToOffset (line, column);
}
public void GetLineColumnFromPosition (int position, out int line, out int column)
{
var loc = data.Document.OffsetToLocation (position);
- line = loc.Line + 1;
- column = loc.Column + 1;
+ line = loc.Line;
+ column = loc.Column;
}
public int InsertText (int position, string text)
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveActionTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveActionTests.cs
index b991d785cf..78ff87d020 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveActionTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/CaretMoveActionTests.cs
@@ -55,7 +55,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
CaretMoveActions.Left (data);
- Assert.AreEqual (new DocumentLocation (2, 3), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (3, 4), data.Caret.Location);
}
[Test()]
@@ -67,7 +67,7 @@ $1234567890
1234567890
1234567890");
CaretMoveActions.Left (data);
- Assert.AreEqual (new DocumentLocation (0, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 11), data.Caret.Location);
}
[Test()]
@@ -78,9 +78,9 @@ $1234567890
1234567890
1234567890
1234567890");
- Assert.AreEqual (new DocumentLocation (0, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 1), data.Caret.Location);
CaretMoveActions.Left (data);
- Assert.AreEqual (new DocumentLocation (0, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 1), data.Caret.Location);
}
[Test()]
@@ -92,7 +92,7 @@ $1234567890
1234567890
1234567890");
CaretMoveActions.Right (data);
- Assert.AreEqual (new DocumentLocation (2, 5), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (3, 6), data.Caret.Location);
}
[Test()]
@@ -104,7 +104,7 @@ $1234567890
1234567890
1234567890");
CaretMoveActions.Right (data);
- Assert.AreEqual (new DocumentLocation (1, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (2, 1), data.Caret.Location);
}
[Test()]
@@ -115,9 +115,9 @@ $1234567890
1234567890
1234567890
1234567890$");
- Assert.AreEqual (new DocumentLocation (4, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (5, 11), data.Caret.Location);
CaretMoveActions.Right (data);
- Assert.AreEqual (new DocumentLocation (4, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (5, 11), data.Caret.Location);
}
[Test()]
@@ -128,9 +128,9 @@ $1234567890
1234$567890
1234567890
1234567890");
- Assert.AreEqual (new DocumentLocation (2, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (3, 5), data.Caret.Location);
CaretMoveActions.Up (data);
- Assert.AreEqual (new DocumentLocation (1, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (2, 5), data.Caret.Location);
}
[Test()]
@@ -141,9 +141,9 @@ $1234567890
1234567890
1234567890
1234567890");
- Assert.AreEqual (new DocumentLocation (0, 2), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 3), data.Caret.Location);
CaretMoveActions.Up (data);
- Assert.AreEqual (new DocumentLocation (0, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 1), data.Caret.Location);
}
[Test()]
@@ -154,9 +154,9 @@ $1234567890
1234$567890
1234567890
1234567890");
- Assert.AreEqual (new DocumentLocation (2, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (3, 5), data.Caret.Location);
CaretMoveActions.Down (data);
- Assert.AreEqual (new DocumentLocation (3, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (4, 5), data.Caret.Location);
}
[Test()]
@@ -167,49 +167,49 @@ $1234567890
1234567890
1234567890
123$4567890");
- Assert.AreEqual (new DocumentLocation (4, 3), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (5, 4), data.Caret.Location);
CaretMoveActions.Down (data);
- Assert.AreEqual (new DocumentLocation (4, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (5, 11), data.Caret.Location);
}
[Test()]
public void TestCaretLineHome ()
{
TextEditorData data = Create (@" 345$67890");
- Assert.AreEqual (new DocumentLocation (0, 5), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 6), data.Caret.Location);
CaretMoveActions.LineHome (data);
- Assert.AreEqual (new DocumentLocation (0, 2), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 3), data.Caret.Location);
CaretMoveActions.LineHome (data);
- Assert.AreEqual (new DocumentLocation (0, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 1), data.Caret.Location);
CaretMoveActions.LineHome (data);
- Assert.AreEqual (new DocumentLocation (0, 2), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 3), data.Caret.Location);
}
[Test()]
public void TestCaretLineEnd ()
{
TextEditorData data = Create (@"12345$67890");
- Assert.AreEqual (new DocumentLocation (0, 5), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 6), data.Caret.Location);
CaretMoveActions.LineEnd (data);
- Assert.AreEqual (new DocumentLocation (0, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 11), data.Caret.Location);
}
[Test()]
public void TestToDocumentStart ()
{
TextEditorData data = Create (@"12345$67890");
- Assert.AreEqual (new DocumentLocation (0, 5), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 6), data.Caret.Location);
CaretMoveActions.ToDocumentStart (data);
- Assert.AreEqual (new DocumentLocation (0, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 1), data.Caret.Location);
}
[Test()]
public void TestToDocumentEnd ()
{
TextEditorData data = Create (@"12345$67890");
- Assert.AreEqual (new DocumentLocation (0, 5), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 6), data.Caret.Location);
CaretMoveActions.ToDocumentEnd (data);
- Assert.AreEqual (new DocumentLocation (0, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 11), data.Caret.Location);
}
[TestFixtureSetUp]
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/DeleteActionTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/DeleteActionTests.cs
index 1d7ada3b01..7f0029ae82 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/DeleteActionTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/DeleteActionTests.cs
@@ -36,9 +36,9 @@ namespace Mono.TextEditor.Tests
public void TestBackspace ()
{
TextEditorData data = CaretMoveActionTests.Create (@"1234$567890");
- Assert.AreEqual (new DocumentLocation (0, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 5), data.Caret.Location);
DeleteActions.Backspace (data);
- Assert.AreEqual (new DocumentLocation (0, 3), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 4), data.Caret.Location);
Assert.AreEqual ("123567890", data.Document.Text);
}
@@ -47,7 +47,7 @@ namespace Mono.TextEditor.Tests
{
TextEditorData data = CaretMoveActionTests.Create (@"$1234567890");
DeleteActions.Backspace (data);
- Assert.AreEqual (new DocumentLocation (0, 0), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 1), data.Caret.Location);
Assert.AreEqual ("1234567890", data.Document.Text);
}
@@ -55,9 +55,9 @@ namespace Mono.TextEditor.Tests
public void TestDelete ()
{
TextEditorData data = CaretMoveActionTests.Create (@"1234$567890");
- Assert.AreEqual (new DocumentLocation (0, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 5), data.Caret.Location);
DeleteActions.Delete (data);
- Assert.AreEqual (new DocumentLocation (0, 4), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 5), data.Caret.Location);
Assert.AreEqual ("123467890", data.Document.Text);
}
@@ -66,7 +66,7 @@ namespace Mono.TextEditor.Tests
{
TextEditorData data = CaretMoveActionTests.Create (@"1234567890$");
DeleteActions.Delete (data);
- Assert.AreEqual (new DocumentLocation (0, 10), data.Caret.Location);
+ Assert.AreEqual (new DocumentLocation (1, 11), data.Caret.Location);
Assert.AreEqual ("1234567890", data.Document.Text);
}
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertNewLineTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertNewLineTests.cs
index cca7cc2de1..5e8633744a 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertNewLineTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertNewLineTests.cs
@@ -38,11 +38,11 @@ namespace Mono.TextEditor.Tests
{
TextEditorData data = new Mono.TextEditor.TextEditorData ();
data.Document.Text = "Hello World!";
- data.Caret.Location = new DocumentLocation (0, "Hello".Length);
+ data.Caret.Location = new DocumentLocation (1, "Hello".Length + 1);
MiscActions.InsertNewLine (data);
Assert.AreEqual (2, data.Document.LineCount);
- Assert.AreEqual (1, data.Caret.Line);
- Assert.AreEqual (0, data.Caret.Column);
+ Assert.AreEqual (2, data.Caret.Line);
+ Assert.AreEqual (1, data.Caret.Column);
Assert.AreEqual ("Hello" + Environment.NewLine + " World!", data.Document.Text);
}
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertTabTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertTabTests.cs
index 772badb408..010611890a 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertTabTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/InsertTabTests.cs
@@ -76,12 +76,12 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.EndOffset, data.Caret.Offset);*/
- Assert.IsTrue (data.Document.GetLine(1).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(2).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(3).Length > data.Document.GetLine(0).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(4).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(3).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 1).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 2).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 3).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 4).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
}
[Test()]
@@ -104,12 +104,12 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.Offset, data.Caret.Offset);*/
- Assert.IsTrue (data.Document.GetLine(1).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(2).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(3).Length > data.Document.GetLine(0).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(4).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(3).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 1).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 2).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 3).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 4).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
}
[Test()]
@@ -132,11 +132,11 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.EndOffset, data.Caret.Offset);*/
- Assert.IsTrue (data.Document.GetLine(1).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(2).Length > data.Document.GetLine(0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 1).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 2).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(3).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
}
[Test()]
@@ -159,11 +159,11 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.EndOffset, data.Caret.Offset);*/
- Assert.IsTrue (data.Document.GetLine(1).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(2).Length > data.Document.GetLine(0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 1).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 2).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(3).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
}
[Test()]
@@ -186,11 +186,11 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.Offset, data.Caret.Offset);*/
- Assert.IsTrue (data.Document.GetLine(1).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(2).Length > data.Document.GetLine(0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 1).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 2).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(3).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
}
[Test()]
@@ -212,13 +212,13 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.EndOffset, data.Caret.Offset);*/
- Assert.AreEqual (data.Document.GetLine(1).Offset, data.SelectionRange.Offset);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Offset, data.SelectionRange.Offset);
- Assert.IsTrue (data.Document.GetLine(1).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(2).Length > data.Document.GetLine(0).Length);
- Assert.IsTrue (data.Document.GetLine(3).Length > data.Document.GetLine(0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 1).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 2).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 3).Length > data.Document.GetLine (DocumentLocation.MinLine + 0).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
}
[TestFixtureSetUp]
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/RemoveTabTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/RemoveTabTests.cs
index ac10c850af..c1165e0313 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/RemoveTabTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/RemoveTabTests.cs
@@ -55,14 +55,14 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.Caret.Offset);
Assert.AreEqual (currentSelection.Offset, data.SelectionAnchor);*/
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(1).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(2).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(3).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 1).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(4).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 4).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
}
[Test()]
@@ -86,14 +86,14 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.Offset, data.Caret.Offset);
Assert.AreEqual (currentSelection.EndOffset, data.SelectionAnchor);*/
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(1).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(2).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(3).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 1).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(4).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 4).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
}
[Test()]
@@ -116,16 +116,16 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (currentSelection.EndOffset, data.SelectionRange.EndOffset);
Assert.AreEqual (currentSelection.EndOffset, data.Caret.Offset);
Assert.AreEqual (currentSelection.Offset, data.SelectionAnchor);
- Assert.AreEqual (currentSelection.Offset, data.Document.GetLine(1).Offset);*/
+ Assert.AreEqual (currentSelection.Offset, data.Document.GetLine (DocumentLocation.MinLine + 1).Offset);*/
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(1).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(2).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(3).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 1).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(4).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 4).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
}
[Test()]
@@ -150,14 +150,14 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (0, data.Caret.Column);
Assert.AreEqual (currentSelection.EndOffset, data.SelectionAnchor);*/
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(1).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(2).Length);
- Assert.IsTrue (data.Document.GetLine(0).Length < data.Document.GetLine(3).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 1).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.IsTrue (data.Document.GetLine (DocumentLocation.MinLine + 0).Length < data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
- Assert.AreEqual (data.Document.GetLine(0).Length, data.Document.GetLine(4).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 0).Length, data.Document.GetLine (DocumentLocation.MinLine + 4).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(2).Length);
- Assert.AreEqual (data.Document.GetLine(1).Length, data.Document.GetLine(3).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 2).Length);
+ Assert.AreEqual (data.Document.GetLine (DocumentLocation.MinLine + 1).Length, data.Document.GetLine (DocumentLocation.MinLine + 3).Length);
}
[TestFixtureSetUp]
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/SelectionActionTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/SelectionActionTests.cs
index 2edfaefe86..4952fac3a2 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/SelectionActionTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests.DefaultEditActions/SelectionActionTests.cs
@@ -41,7 +41,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveLeft (data);
- Assert.AreEqual (new Selection (2, 4, 2, 3), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 3), data.MainSelection);
}
[Test()]
@@ -53,7 +53,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveRight (data);
- Assert.AreEqual (new Selection (2, 4, 2, 5), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 5), data.MainSelection);
}
[Test()]
@@ -65,7 +65,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveDown (data);
- Assert.AreEqual (new Selection (2, 4, 3, 4), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 3, DocumentLocation.MinColumn + 4), data.MainSelection);
}
[Test()]
@@ -77,7 +77,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveUp (data);
- Assert.AreEqual (new Selection (2, 4, 1, 4), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 1, DocumentLocation.MinColumn + 4), data.MainSelection);
}
[Test()]
@@ -89,7 +89,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveToDocumentStart (data);
- Assert.AreEqual (new Selection (2, 4, 0, 0), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine, DocumentLocation.MinColumn), data.MainSelection);
}
[Test()]
@@ -101,7 +101,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveToDocumentEnd (data);
- Assert.AreEqual (new Selection (2, 4, 4, 10), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 4, DocumentLocation.MinColumn + 10), data.MainSelection);
}
[Test()]
@@ -113,7 +113,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveLineEnd (data);
- Assert.AreEqual (new Selection (2, 4, 2, 10), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 10), data.MainSelection);
}
[Test()]
@@ -125,7 +125,7 @@ namespace Mono.TextEditor.Tests
1234567890
1234567890");
SelectionActions.MoveLineHome (data);
- Assert.AreEqual (new Selection (2, 4, 2, 0), data.MainSelection);
+ Assert.AreEqual (new Selection (DocumentLocation.MinLine + 2, DocumentLocation.MinColumn + 4, DocumentLocation.MinLine + 2, DocumentLocation.MinColumn), data.MainSelection);
}
[Test()]
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/DocumentTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/DocumentTests.cs
index 7430c09263..9319759215 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/DocumentTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/DocumentTests.cs
@@ -99,7 +99,7 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (document.Text, testText);
((IBuffer)document).Remove (0, document.Length);
- LineSegment line = document.GetLine (0);
+ LineSegment line = document.GetLine (1);
Assert.AreEqual (0, line.Offset);
Assert.AreEqual (0, line.Length);
Assert.AreEqual (0, document.Length);
@@ -114,11 +114,11 @@ namespace Mono.TextEditor.Tests
string top = "1234567890";
document.Text = top;
- Assert.AreEqual (document.GetLine (0).Length, document.Length);
+ Assert.AreEqual (document.GetLine (1).Length, document.Length);
((IBuffer)document).Remove(0, document.Length);
- LineSegment line = document.GetLine (0);
+ LineSegment line = document.GetLine (1);
Assert.AreEqual(0, line.Offset);
Assert.AreEqual(0, line.Length);
Assert.AreEqual(0, document.Length);
@@ -137,7 +137,7 @@ namespace Mono.TextEditor.Tests
((IBuffer)document).Insert (top.Length, testText);
- LineSegment line = document.GetLine (document.LineCount - 1);
+ LineSegment line = document.GetLine (document.LineCount);
Assert.AreEqual (top.Length - 1, line.Offset);
Assert.AreEqual (testText.Length + 1, line.Length);
@@ -152,13 +152,13 @@ namespace Mono.TextEditor.Tests
}
Assert.AreEqual (101, document.LineCount);
for (int i = 0; i < 100; i++) {
- LineSegment line = document.GetLine (i);
+ LineSegment line = document.GetLine (i + 1 );
Assert.AreEqual (99 - i, line.EditableLength);
Assert.AreEqual (Environment.NewLine.Length, line.DelimiterLength);
}
for (int i = 0; i < 100; i++) {
- LineSegment line = document.GetLine (0);
+ LineSegment line = document.GetLine (1);
((IBuffer)document).Remove (line.EditableLength, line.DelimiterLength);
}
Assert.AreEqual (1, document.LineCount);
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/EditActionsTest.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/EditActionsTest.cs
index 74f1560bf7..db64ee7a95 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/EditActionsTest.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/EditActionsTest.cs
@@ -42,8 +42,8 @@ namespace Mono.TextEditor.Tests
{
TextEditorData data = new Mono.TextEditor.TextEditorData ();
data.Document.Text = "\n\n\n\n\n";
- data.Caret.Offset = data.Document.GetLine (1).Offset; // 2nd.Line
- data.MainSelection = new Selection (1,0, 3, 0);
+ data.Caret.Offset = data.Document.GetLine (2).Offset; // 2nd.Line
+ data.MainSelection = new Selection (2, 1, 4, 1);
MiscActions.InsertTab (data);
MiscActions.InsertTab (data);
@@ -55,8 +55,8 @@ namespace Mono.TextEditor.Tests
{
TextEditorData data = new Mono.TextEditor.TextEditorData ();
data.Document.Text = "\n\t\t\n\t\t\n\t\t\n\n";
- data.Caret.Offset = data.Document.GetLine (1).Offset; // 2nd.Line
- data.MainSelection = new Selection (1,0, 3, 0);
+ data.Caret.Offset = data.Document.GetLine (2).Offset; // 2nd.Line
+ data.MainSelection = new Selection (2, 1, 4, 1);
MiscActions.RemoveTab (data);
MiscActions.RemoveTab (data);
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs
index 4b58d636d0..d0009f7774 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/FoldingTests.cs
@@ -126,10 +126,8 @@ namespace Mono.TextEditor.Tests
do {
Gtk.Application.RunIteration ();
} while (!document.HasFoldSegments);
- Assert.AreEqual (12, document.VisualToLogicalLine (4));
- Assert.AreEqual (17, document.VisualToLogicalLine (7));
+ Assert.AreEqual (13, document.VisualToLogicalLine (5));
+ Assert.AreEqual (18, document.VisualToLogicalLine (8));
}
-
-
}
}
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/InsertionModeTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/InsertionModeTests.cs
index c833292e07..55fbf60f7f 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/InsertionModeTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/InsertionModeTests.cs
@@ -46,6 +46,7 @@ namespace Mono.TextEditor.Tests
TextEditor editor = new TextEditor ();
editor.Document.Text = input.Substring (0, idx) + input.Substring (idx + 1);
InsertionPoint point = new InsertionPoint (editor.Document.OffsetToLocation (idx), before, after);
+ Console.WriteLine (point);
point.Insert (editor, text);
return editor.Document.Text;
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/LineSplitterTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/LineSplitterTests.cs
index 3079074f55..6f76c13fc4 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/LineSplitterTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/LineSplitterTests.cs
@@ -44,15 +44,15 @@ namespace Mono.TextEditor.Tests
splitter.TextReplaced (null, new ReplaceEventArgs (0, 0, buffer.Text));
Assert.AreEqual (4, splitter.Count);
for (int i = 0; i < 3; i++) {
- Assert.AreEqual (i * 2, splitter.Get (i).Offset);
- Assert.AreEqual (1, splitter.Get (i).EditableLength);
- Assert.AreEqual (1, splitter.Get (i).DelimiterLength);
- Assert.AreEqual (2, splitter.Get (i).Length);
+ Assert.AreEqual (i * 2, splitter.Get (i + 1).Offset);
+ Assert.AreEqual (1, splitter.Get (i + 1).EditableLength);
+ Assert.AreEqual (1, splitter.Get (i + 1).DelimiterLength);
+ Assert.AreEqual (2, splitter.Get (i + 1).Length);
}
- Assert.AreEqual (3 * 2, splitter.Get (3).Offset);
- Assert.AreEqual (0, splitter.Get (3).EditableLength);
- Assert.AreEqual (0, splitter.Get (3).DelimiterLength);
- Assert.AreEqual (0, splitter.Get (3).Length);
+ Assert.AreEqual (3 * 2, splitter.Get (4).Offset);
+ Assert.AreEqual (0, splitter.Get (4).EditableLength);
+ Assert.AreEqual (0, splitter.Get (4).DelimiterLength);
+ Assert.AreEqual (0, splitter.Get (4).Length);
}
[Test()]
@@ -68,10 +68,10 @@ namespace Mono.TextEditor.Tests
Assert.AreEqual (3, splitter.Count);
- Assert.AreEqual (2 * 2, splitter.Get (2).Offset);
- Assert.AreEqual (0, splitter.Get (2).EditableLength);
- Assert.AreEqual (0, splitter.Get (2).DelimiterLength);
- Assert.AreEqual (0, splitter.Get (2).Length);
+ Assert.AreEqual (2 * 2, splitter.Get (3).Offset);
+ Assert.AreEqual (0, splitter.Get (3).EditableLength);
+ Assert.AreEqual (0, splitter.Get (3).DelimiterLength);
+ Assert.AreEqual (0, splitter.Get (3).Length);
}
}
}
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/SelectionTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/SelectionTests.cs
index ffeb49aeab..addb9cee01 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/SelectionTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/SelectionTests.cs
@@ -181,7 +181,7 @@ data.Document.Text =
2
3
";
- data.SetSelectLines (0, 3);
+ data.SetSelectLines (1, 4);
Assert.AreEqual (0, data.SelectionAnchor);
Assert.AreEqual (0, data.SelectionRange.Offset);
Assert.AreEqual (data.Document.Length, data.SelectionRange.EndOffset);
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/ViTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/ViTests.cs
index 98469b6ecb..eb5a408f58 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/ViTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/ViTests.cs
@@ -39,19 +39,19 @@ namespace Mono.TextEditor.Tests
public void ColumnMotion ()
{
var mode = new TestViEditMode () { Text = "Test\nText" };
- Assert.AreEqual (0, mode.Col);
- mode.Input ('l');
Assert.AreEqual (1, mode.Col);
+ mode.Input ('l');
+ Assert.AreEqual (2, mode.Col);
mode.Input ("ll");
- Assert.AreEqual (3, mode.Col);
+ Assert.AreEqual (4, mode.Col);
mode.Input ('l');
- Assert.AreEqual (3, mode.Col);
+ Assert.AreEqual (4, mode.Col);
mode.Input ("hh");
- Assert.AreEqual (1, mode.Col);
+ Assert.AreEqual (2, mode.Col);
mode.Input ('h');
- Assert.AreEqual (0, mode.Col);
+ Assert.AreEqual (1, mode.Col);
mode.Input ('h');
- Assert.AreEqual (0, mode.Col);
+ Assert.AreEqual (1, mode.Col);
}
[Test]
@@ -64,19 +64,19 @@ qrstu
vwxyz",
};
mode.Caret.Offset = 0;
- Assert.AreEqual (0, mode.Line);
- mode.Input ('j');
Assert.AreEqual (1, mode.Line);
+ mode.Input ('j');
+ Assert.AreEqual (2, mode.Line);
mode.Input ('k');
- Assert.AreEqual (0, mode.Line);
+ Assert.AreEqual (1, mode.Line);
mode.Input ("jjjj");
- Assert.AreEqual (3, mode.Line);
- mode.Caret.Line = 1;
- mode.Caret.Column = 11;
+ Assert.AreEqual (4, mode.Line);
+ mode.Caret.Line = 2;
+ mode.Caret.Column = 12;
mode.Input ('j');
- Assert.AreEqual (4, mode.Col);
+ Assert.AreEqual (5, mode.Col);
mode.Input ('k');
- Assert.AreEqual (11, mode.Col);
+ Assert.AreEqual (12, mode.Col);
}
[Test]
@@ -114,8 +114,8 @@ qrstu",
ccc ccc",
};
mode.Input ("jwlldd");
- Assert.AreEqual (1, mode.Line);
- Assert.AreEqual (3, mode.Col);
+ Assert.AreEqual (2, mode.Line);
+ Assert.AreEqual (4, mode.Col);
Assert.AreEqual (
@" aaa aaa
ccc ccc", mode.Text);
@@ -176,7 +176,7 @@ qrstu",
bbb bbb
ggg ggg
ggg ggg", mode.Text);
- Assert.AreEqual (4, mode.Line);
+ Assert.AreEqual (5, mode.Line);
//movement to/across boundaries, check selection still okay by deleting lines 1/2/3
mode.Input ("kVlllllhhhhhhhhhhjjjhhhhhjjjjkkkkkkkkkkkkjd");
Assert.AreEqual (
@@ -225,25 +225,25 @@ kkk lll", mode.Text);
};
//move 2 lines down, 2 words in, enter visual mode
mode.Input ("jjwwv");
- mode.AssertSelection (2, 7, 2, 8);
+ mode.AssertSelection (3, 8, 3, 9);
//2 letters to right
mode.Input ("ll");
- mode.AssertSelection (2, 7, 2, 10);
+ mode.AssertSelection (3, 8, 3, 11);
//4 letters to left
mode.Input ("hhhh");
- mode.AssertSelection (2, 8, 2, 5);
+ mode.AssertSelection (3, 9, 3, 6);
//1 line up
mode.Input ("k");
- mode.AssertSelection (2, 8, 1, 5);
+ mode.AssertSelection (3, 9, 2, 6);
//1 line up
mode.Input ("k");
- mode.AssertSelection (2, 8, 0, 5);
+ mode.AssertSelection (3, 9, 1, 6);
//5 letters to right
mode.Input ("lllll");
- mode.AssertSelection (2, 8, 0, 10);
+ mode.AssertSelection (3, 9, 1, 11);
//3 lines down
mode.Input ("jjj");
- mode.AssertSelection (2, 7, 3, 11);
+ mode.AssertSelection (3, 8, 4, 12);
}
[Test]
@@ -273,8 +273,10 @@ kkk lll", mode.Text);
{
public TestViEditMode () : this (new TextEditorData ())
{
+ Console.WriteLine ("!1111");
Data.Options.WordFindStrategy = new Mono.TextEditor.Vi.ViWordFindStrategy ();
Data.Options.RemoveTrailingWhitespaces = true;
+ Console.WriteLine ("!!!!!!");
}
//used to prevent edit actions from the HandleKeypress causing Caret/SelectionPositionChanged
@@ -283,8 +285,11 @@ kkk lll", mode.Text);
public TestViEditMode (TextEditorData data)
{
data.CurrentMode = this;
- var f = typeof (EditMode).GetField ("textEditorData", BindingFlags.NonPublic | BindingFlags.Instance);
- f.SetValue (this, data);
+ textEditorData = data;
+ // Currently doesn't work on my mac (test doesn't terminate with mono 2.6.7).
+ // var f = typeof (EditMode).GetField ("textEditorData", BindingFlags.NonPublic | BindingFlags.Instance);
+ // f.SetValue (this, data);
+
data.Caret.PositionChanged += delegate(object sender, DocumentLocationEventArgs e) {
if (!inputting)
this.CaretPositionChanged ();
diff --git a/main/tests/UnitTests/Mono.TextEditor.Tests/VirtualSpacesTests.cs b/main/tests/UnitTests/Mono.TextEditor.Tests/VirtualSpacesTests.cs
index a25498ccd5..3adb1bee6a 100644
--- a/main/tests/UnitTests/Mono.TextEditor.Tests/VirtualSpacesTests.cs
+++ b/main/tests/UnitTests/Mono.TextEditor.Tests/VirtualSpacesTests.cs
@@ -44,7 +44,7 @@ namespace Mono.TextEditor.Tests
data.Document.Text = "\n\nHello World\n";
data.Caret.Offset = 1; // 2nd.Line
data.Caret.AllowCaretBehindLineEnd = true;
- data.Caret.Column = 4;
+ data.Caret.Column = DocumentLocation.MinColumn + 4;
Clipboard clipboard = Clipboard.Get (Mono.TextEditor.ClipboardActions.CopyOperation.CLIPBOARD_ATOM);
clipboard.Text = "Test";
@@ -63,7 +63,7 @@ namespace Mono.TextEditor.Tests
data.Document.Text = "\n\n\n";
data.Caret.Offset = 1; // 2nd.Line
data.Caret.AllowCaretBehindLineEnd = true;
- data.Caret.Column = 4;
+ data.Caret.Column = DocumentLocation.MinColumn + 4;
DeleteActions.Backspace (data);
Assert.AreEqual ("\n\n\n", data.Document.Text);
@@ -77,7 +77,7 @@ namespace Mono.TextEditor.Tests
data.Document.Text = "\n\n\n";
data.Caret.Offset = 1; // 2nd.Line
data.Caret.AllowCaretBehindLineEnd = true;
- data.Caret.Column = 4;
+ data.Caret.Column = DocumentLocation.MinColumn + 4;
data.Options.RemoveTrailingWhitespaces = false;
MiscActions.InsertNewLine (data);
@@ -94,10 +94,10 @@ namespace Mono.TextEditor.Tests
data.Document.Text = "\n \n\n";
data.Caret.AllowCaretBehindLineEnd = true;
data.Caret.Offset = 2; // 2nd.Line
- Assert.AreEqual (1, data.Caret.Column);
- Document.RemoveTrailingWhitespaces (data, data.Document.GetLine (1));
+ Assert.AreEqual (DocumentLocation.MinColumn + 1, data.Caret.Column);
+ Document.RemoveTrailingWhitespaces (data, data.Document.GetLine (2));
Assert.AreEqual ("\n\n\n", data.Document.Text);
- Assert.AreEqual (1, data.Caret.Column);
+ Assert.AreEqual (DocumentLocation.MinColumn + 1, data.Caret.Column);
}
}
diff --git a/main/tests/UnitTests/MonoDevelop.AspNet/AspNetTesting.cs b/main/tests/UnitTests/MonoDevelop.AspNet/AspNetTesting.cs
index e17c2cc073..0876250c84 100644
--- a/main/tests/UnitTests/MonoDevelop.AspNet/AspNetTesting.cs
+++ b/main/tests/UnitTests/MonoDevelop.AspNet/AspNetTesting.cs
@@ -88,7 +88,7 @@ namespace MonoDevelop.AspNet.Tests
int line, column;
sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column);
ctx.TriggerLine = line;
- ctx.TriggerLineOffset = column;
+ ctx.TriggerLineOffset = column - 1;
if (isCtrlSpace)
return textEditorCompletion.CodeCompletionCommand (ctx) as CompletionDataList;
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/CodeCompletionBugTests.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/CodeCompletionBugTests.cs
index e2060208c4..afef32f4a3 100644
--- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/CodeCompletionBugTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/CodeCompletionBugTests.cs
@@ -100,7 +100,7 @@ namespace MonoDevelop.CSharpBinding.Tests
int line, column;
sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column);
ctx.TriggerLine = line;
- ctx.TriggerLineOffset = column;
+ ctx.TriggerLineOffset = column - 1;
if (isCtrlSpace)
return textEditorCompletion.CodeCompletionCommand (ctx) as CompletionDataList;
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/FindMemberVisitorTests.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/FindMemberVisitorTests.cs
index 1e0dddd8ba..08c0909c6c 100644
--- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/FindMemberVisitorTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/FindMemberVisitorTests.cs
@@ -131,7 +131,7 @@ namespace MonoDevelop.CSharpBinding.Tests
if (expectedReferences[i].Line < astVisitor.FoundReferences[j].Line) {
errorText.Append ("Reference at line " + expectedReferences[i].Line + " not found.");
errorText.AppendLine ();
- errorText.Append (doc.GetTextAt (doc.GetLine (expectedReferences[i].Line - 1)).Replace ('\t', ' '));
+ errorText.Append (doc.GetTextAt (doc.GetLine (expectedReferences[i].Line)).Replace ('\t', ' '));
errorText.AppendLine ();
errorText.Append (new string (' ', expectedReferences[i].Column));errorText.Append ('^');
errorText.AppendLine ();
@@ -141,7 +141,7 @@ namespace MonoDevelop.CSharpBinding.Tests
if (expectedReferences[i].Line > astVisitor.FoundReferences[j].Line) {
errorText.Append ("Found unexpected Reference at line " + astVisitor.FoundReferences[j].Line);
errorText.AppendLine ();
- errorText.Append (doc.GetTextAt (doc.GetLine (astVisitor.FoundReferences[j].Line - 1)).Replace ('\t', ' '));
+ errorText.Append (doc.GetTextAt (doc.GetLine (astVisitor.FoundReferences[j].Line)).Replace ('\t', ' '));
errorText.AppendLine ();
errorText.Append (new string (' ', astVisitor.FoundReferences[j].Column));errorText.Append ('^');
errorText.AppendLine ();
@@ -151,7 +151,7 @@ namespace MonoDevelop.CSharpBinding.Tests
errorText.Append ("Column mismatch at line " + astVisitor.FoundReferences[j].Line + " was: " + astVisitor.FoundReferences[j].Column + " should be:" + expectedReferences[i].Column);
errorText.AppendLine ();
- errorText.Append (doc.GetTextAt (doc.GetLine (astVisitor.FoundReferences[j].Line - 1)).Replace ('\t', ' '));
+ errorText.Append (doc.GetTextAt (doc.GetLine (astVisitor.FoundReferences[j].Line)).Replace ('\t', ' '));
errorText.Append (new string (' ', expectedReferences[i].Column));errorText.Append ('^');
errorText.AppendLine ();
errorText.Append (new string (' ', astVisitor.FoundReferences[j].Column));errorText.Append ('^');
@@ -162,7 +162,7 @@ namespace MonoDevelop.CSharpBinding.Tests
while (i < expectedReferences.Count) {
errorText.Append ("Reference at line " + expectedReferences[i].Line + " not found.");
errorText.AppendLine ();
- errorText.Append (doc.GetTextAt (doc.GetLine (expectedReferences[i].Line - 1)).Replace ('\t', ' '));
+ errorText.Append (doc.GetTextAt (doc.GetLine (expectedReferences[i].Line)).Replace ('\t', ' '));
errorText.AppendLine ();
errorText.Append (new string (' ', expectedReferences[j].Column));errorText.Append ('^');
errorText.AppendLine ();
@@ -171,7 +171,7 @@ namespace MonoDevelop.CSharpBinding.Tests
while (j < astVisitor.FoundReferences.Count) {
errorText.Append ("Found unexpected Reference at line " + astVisitor.FoundReferences[j].Line);
errorText.AppendLine ();
- errorText.Append (doc.GetTextAt (doc.GetLine (astVisitor.FoundReferences[j].Line - 1)).Replace ('\t', ' '));
+ errorText.Append (doc.GetTextAt (doc.GetLine (astVisitor.FoundReferences[j].Line)).Replace ('\t', ' '));
errorText.AppendLine ();
errorText.Append (new string (' ', astVisitor.FoundReferences[i].Column));errorText.Append ('^');
errorText.AppendLine ();
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/ParameterCompletionTests.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/ParameterCompletionTests.cs
index e91cd1e472..9a592d9e82 100644
--- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/ParameterCompletionTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/ParameterCompletionTests.cs
@@ -85,7 +85,7 @@ namespace MonoDevelop.CSharpBinding.Tests
int line, column;
sev.GetLineColumnFromPosition (sev.CursorPosition, out line, out column);
ctx.TriggerLine = line;
- ctx.TriggerLineOffset = column;
+ ctx.TriggerLineOffset = column - 1;
IParameterDataProvider result = textEditorCompletion.HandleParameterCompletion (ctx, editorText[cursorPosition - 1]);
ProjectDomService.Unload (project);
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs
index d635b9917a..7908c75bff 100644
--- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs
+++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs
@@ -109,14 +109,14 @@ namespace MonoDevelop.CSharpBinding.Tests
public int GetPositionFromLineColumn (int line, int column)
{
- return document.LocationToOffset (line - 1, column - 1);
+ return document.LocationToOffset (line, column);
}
public void GetLineColumnFromPosition (int position, out int line, out int column)
{
DocumentLocation loc = document.OffsetToLocation (position);
- line = loc.Line + 1;
- column = loc.Column + 1;
+ line = loc.Line;
+ column = loc.Column;
}
public string SelectedText { get { return ""; } set { } }
diff --git a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs
index 83d279381e..7cd61f6236 100644
--- a/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Refactoring/ExtractMethodTests.cs
@@ -116,7 +116,7 @@ namespace MonoDevelop.Refactoring.Tests
} else {
expressionResult = new NewCSharpExpressionFinder (dom).FindFullExpression (doc.Editor, cursorPosition + 1);
}
- ResolveResult resolveResult = endPos >= 0 ? resolver.Resolve (expressionResult, new DomLocation (doc.Editor.Caret.Line + 1, doc.Editor.Caret.Column + 1)) : null;
+ ResolveResult resolveResult = endPos >= 0 ? resolver.Resolve (expressionResult, new DomLocation (doc.Editor.Caret.Line, doc.Editor.Caret.Column)) : null;
RefactoringOptions result = new RefactoringOptions {
Document = doc,
@@ -180,7 +180,7 @@ namespace MonoDevelop.Refactoring.Tests
ExtractMethodRefactoring.ExtractMethodParameters parameters = refactoring.CreateParameters (options);
Assert.IsNotNull (parameters);
parameters.Name = "NewMethod";
- parameters.InsertionPoint = new Mono.TextEditor.InsertionPoint (new DocumentLocation (options.ResolveResult.CallingMember.BodyRegion.End.Line, 0), NewLineInsertion.BlankLine, NewLineInsertion.None);
+ parameters.InsertionPoint = new Mono.TextEditor.InsertionPoint (new DocumentLocation (options.ResolveResult.CallingMember.BodyRegion.End.Line, 1), NewLineInsertion.BlankLine, NewLineInsertion.None);
List<Change> changes = refactoring.PerformChanges (options, parameters);
string output = GetOutput (options, changes);
Assert.IsTrue (CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
diff --git a/main/tests/UnitTests/MonoDevelop.Refactoring/GenerateNewMemberTests.cs b/main/tests/UnitTests/MonoDevelop.Refactoring/GenerateNewMemberTests.cs
index 252eeb1f3e..c47c542c39 100644
--- a/main/tests/UnitTests/MonoDevelop.Refactoring/GenerateNewMemberTests.cs
+++ b/main/tests/UnitTests/MonoDevelop.Refactoring/GenerateNewMemberTests.cs
@@ -110,7 +110,6 @@ namespace MonoDevelop.Refactoring.Tests
var foundPoints = HelperMethods.GetInsertionPoints (data.Document, parseResult.CompilationUnit.Types[0]);
Assert.AreEqual (loc.Count, foundPoints.Count, "point count doesn't match");
for (int i = 0; i < loc.Count; i++) {
- Console.WriteLine (loc[i] + "/" + foundPoints[i]);
Assert.AreEqual (loc[i].Location, foundPoints[i].Location, "point " + i + " doesn't match");
Assert.AreEqual (loc[i].LineAfter, foundPoints[i].LineAfter, "point " + i + " ShouldInsertNewLineAfter doesn't match");
Assert.AreEqual (loc[i].LineBefore, foundPoints[i].LineBefore, "point " + i + " ShouldInsertNewLineBefore doesn't match");