OSDN Git Service

一文字しかない状況でBSキーを押すと例外が発生するバグを修正した
authorgdkhd812 <jbh03215@htmil.co.jp>
Tue, 3 Sep 2013 09:41:47 +0000 (18:41 +0900)
committergdkhd812 <jbh03215@htmil.co.jp>
Tue, 3 Sep 2013 09:41:47 +0000 (18:41 +0900)
Common/LineToIndex.cs

index 572c46e..8ff4a5f 100644 (file)
@@ -334,10 +334,6 @@ namespace FooEditEngine
 \r
         void AddDummyLine()\r
         {\r
-            int lastLineRow = this.Lines.Count > 0 ? this.Lines.Count - 1 : -1;\r
-            int lastLineHeadIndex = this.GetIndexFromLineNumber(lastLineRow);\r
-            int lastLineLength = this.GetLengthFromLineNumber(lastLineRow);\r
-\r
             //最終行が削除された場合は追加する\r
             LineToIndexTableData dummyLine = null;\r
             if (this.Lines.Count == 0)\r
@@ -345,8 +341,14 @@ namespace FooEditEngine
                 dummyLine = new LineToIndexTableData();\r
                 dummyLine.CreateLayout = this.LineToIndexTableData_CreatLayout;\r
                 this.Lines.Add(dummyLine);\r
+                return;\r
             }\r
-            else if (lastLineLength != 0 && this.Document[Document.Length - 1] == Document.NewLine)\r
+            \r
+            int lastLineRow = this.Lines.Count - 1;\r
+            int lastLineHeadIndex = this.GetIndexFromLineNumber(lastLineRow);\r
+            int lastLineLength = this.GetLengthFromLineNumber(lastLineRow);\r
+\r
+            if (lastLineLength != 0 && this.Document[Document.Length - 1] == Document.NewLine)\r
             {\r
                 dummyLine = new LineToIndexTableData(lastLineHeadIndex + lastLineLength, 0, true, null);\r
                 dummyLine.CreateLayout = this.LineToIndexTableData_CreatLayout;\r