throw new InvalidOperationException("");
if (start < 0 || start + length < 0 || start + length > this.Length)
throw new ArgumentOutOfRangeException("startかendが指定できる範囲を超えてます");
+ //選択範囲が消されたとき
+ foreach (Selection sel in this.Selections)
+ this.LayoutLines.ClearLayoutCache(sel.start, sel.length);
this.Selections.Clear();
if (length < 0)
{
TextPoint startTextPoint = this.LayoutLines.GetTextPointFromIndex(start);
TextPoint endTextPoint = this.LayoutLines.GetTextPointFromIndex(start + length);
this.SelectByRectangle(new TextRectangle(startTextPoint, endTextPoint));
+ this.LayoutLines.ClearLayoutCache(start, length);
}
else if (length != 0)
{
this.Selections.Add(Selection.Create(start, length));
+ this.LayoutLines.ClearLayoutCache(start, length);
}
- this.LayoutLines.ClearLayoutCache();
this.SelectionChanged(this, null);
}
start--;
if (find_sep_func(str[start]))
+ {
start++;
+ }
int end = index;
while (end < this.Length && !find_sep_func(str[end]))
try
{
this.Clear();
- this.LayoutLines.IsFrozneDirtyFlag = true;
await this.buffer.LoadAsync(fs, tokenSource);
}
finally
{
- this.Dirty = false; //ファイルの内容とドキュメントの中身は同じなのでダーティフラグは偽にする
this.PerformLayout();
- //これ以降の操作にだけダーティフラグを適用しないとおかしなことになる
- this.LayoutLines.IsFrozneDirtyFlag = false;
if (this.LoadProgress != null)
this.LoadProgress(this, new ProgressEventArgs(ProgressState.Complete));
}
/// <param name="fs">IStreamWriterオブジェクト</param>
/// <param name="tokenSource">キャンセルトークン</param>
/// <returns>Taskオブジェクト</returns>
- /// <remarks>非同期操作中はこのメソッドを実行することはできません。同時にダーティフラグもクリアされます</remarks>
+ /// <remarks>非同期操作中はこのメソッドを実行することはできません</remarks>
public async Task SaveAsync(TextWriter fs, CancellationTokenSource tokenSource = null)
{
- try
- {
- await this.buffer.LockAsync().ConfigureAwait(false);
- StringBuilder line = new StringBuilder();
- for (int i = 0; i < this.Length; i++)
- {
- char c = this[i];
- line.Append(c);
- if (c == Document.NewLine || i == this.Length - 1)
- {
- string str = line.ToString();
- str = str.Replace(Document.NewLine.ToString(), fs.NewLine);
- await fs.WriteAsync(str).ConfigureAwait(false);
- line.Clear();
- if (tokenSource != null)
- tokenSource.Token.ThrowIfCancellationRequested();
-#if TEST_ASYNC
- System.Threading.Thread.Sleep(10);
-#endif
- }
- }
- this.Dirty = false;
- }
- finally
- {
- this.buffer.UnLock();
- }
+ await this.buffer.SaveAsync(fs, tokenSource);
}
/// <summary>