~ubuntu-branches/ubuntu/natty/monodevelop/natty

« back to all changes in this revision

Viewing changes to src/core/Mono.Texteditor/Mono.TextEditor/Document.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-01-07 19:06:58 UTC
  • mto: (1.6.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 46.
  • Revision ID: james.westby@ubuntu.com-20100107190658-z9z95lgk4kwfes7p
ImportĀ upstreamĀ versionĀ 2.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                SyntaxMode   syntaxMode = null;
43
43
                
44
44
                string mimeType;
45
 
                string fileName;
 
45
                
46
46
                bool   readOnly;
47
47
                ReadOnlyCheckDelegate readOnlyCheckDelegate;
48
48
                
59
59
                }
60
60
                
61
61
                public string FileName {
62
 
                        get {
63
 
                                return fileName;
64
 
                        }
65
 
                        set {
66
 
                                fileName = value;
67
 
                        }
 
62
                        get;
 
63
                        set;
68
64
                }
69
65
                
70
66
                public SyntaxMode SyntaxMode {
878
874
                        {
879
875
                                int result = visualLineNumber;
880
876
                                LineSegment line = doc.GetLine (result);
881
 
                                if (line == null)
882
 
                                        return result;
883
 
                                foreach (FoldSegment segment in Traverse (x => !(x.IsFolded && x.StartLine.Offset < line.Offset))) {
884
 
                                        if (segment.IsFolded && segment.StartLine.Offset < line.Offset) {
 
877
                                // line == null in that loop means that the current visual line number is after the last line. But it has a correct
 
878
                                // logical line number depending on the folds.
 
879
                                foreach (FoldSegment segment in Traverse (x => !(x.IsFolded && (line == null || x.StartLine.Offset < line.Offset)))) {
 
880
                                        if (segment.IsFolded && (line == null || segment.StartLine.Offset < line.Offset)) {
885
881
                                                result += doc.GetLineCount (segment);
886
 
                                                line = doc.GetLine (result);
887
 
                                                if (line == null) 
888
 
                                                        return result;
 
882
                                                if (line != null)
 
883
                                                        line = doc.GetLine (result);
889
884
                                        }
890
 
                                        if (segment.StartLine.Offset > line.Offset)
 
885
                                        if (line != null && segment.StartLine.Offset > line.Offset)
891
886
                                                break;
892
887
                                }
893
888
                                return result;
1045
1040
                        }
1046
1041
                }
1047
1042
                
1048
 
                
1049
1043
                public IEnumerable<FoldSegment> GetFoldingsFromOffset (int offset)
1050
1044
                {
1051
1045
                        if (offset < 0 || offset >= Length)
1109
1103
                }
1110
1104
                #endregion
1111
1105
                
1112
 
 
1113
1106
                public void AddMarker (int lineNumber, TextMarker marker)
1114
1107
                {
1115
1108
                        AddMarker (this.GetLine (lineNumber), marker);
1153
1146
                {
1154
1147
                        if (visualLineNumber <= 0)
1155
1148
                                return 0;
1156
 
                        if (visualLineNumber >= LineCount)
1157
 
                                return visualLineNumber;
1158
1149
                        return this.foldSegmentTree.VisualToLogicalLine (this, visualLineNumber);
1159
1150
                }
1160
1151
                
1343
1334
                        if (line == null)
1344
1335
                                return;
1345
1336
                        int whitespaces = 0;
1346
 
                        for (int i = line.EditableLength - 1; i >= 0 ; i--) {
 
1337
                        for (int i = line.EditableLength - 1; i >= 0; i--) {
1347
1338
                                if (Char.IsWhiteSpace (data.Document.GetCharAt (line.Offset + i))) {
1348
1339
                                        whitespaces++;
1349
1340
                                } else {
1353
1344
                        
1354
1345
                        if (whitespaces > 0) {
1355
1346
                                int offset = line.Offset + line.EditableLength - whitespaces;
1356
 
                                if (data.Caret.Offset > offset)
1357
 
                                        data.Caret.Offset -= whitespaces;
 
1347
                                int caretOffset = data.Caret.Offset;
1358
1348
                                data.Remove (offset, whitespaces);
 
1349
                                if (caretOffset > offset)
 
1350
                                        data.Caret.Offset = caretOffset - whitespaces;
1359
1351
                        }
1360
1352
                }
1361
1353
                #endregion