Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce use of File's internal details #195

Merged
merged 21 commits into from
Feb 17, 2019
Merged

Reduce use of File's internal details #195

merged 21 commits into from
Feb 17, 2019

Conversation

rjkroege
Copy link
Owner

A bunch of cleanups aimed to isolate the internals of File.

Text maintains a cache of text insertions that should be Undo-able
as a group. Relocate this cache into File so that the File API surface
makes a small step closer to the undo.Buffer which encapsulates
undo with well-defined Commit points.

A step towards #97.
Post relocating of the typing cache, cleanup some additional code.
There is a frequent pattern in the code to reach into File's buffer
implementation to determine the number of runes contained in the
File. This impedes replacing File's internal details so switch
external users to the Size function on File objects.

Helps with #97.
Modify File.Commit to have API alignment with undo.Buffer's Commit.
Helps with #97.
Advance the semantic fit between undo.Buffer and File by renaming the
existing Insert and Delete methods to InsertAt and DeleteAt.

Helps #97.
Move the FileHash code into a separate file to simplify the File code. Cleanup
to help with #97.
Refactor the code in Text.Insert to let File.InsertAt (uniformly) invoke
an observer pattern on any insertion. Helps with #97.

NB: not complete. Rebase in follow-on cleanup CLs. In particular,
Undo doesn't redraw the box correctly in this change.
Refactor the code in DeleteAt to run observers. Helps #97. Fixes the
problem with deletion in Zerox Windows noted in the previous CL.
Helps with #97. Moving towards to keeping the observer pattern an
opaque detail.
Reduce the number of places that look into internal details of File by
adding a HasMultipleTexts accessor. Simplifies code for helping #97.
Altering File for #97 permits removing the use of curtext from allupdate.
Rewrite File.Load in terms of File.InsertAt to adapt it to the
undo.Buffer API surface. This also simplifies the code by Re-using the
new observer structure. Helps with #97.
File.Close does not map to undo.Buffer so clean up this and some other
unnecessary code. Helps with #97.
Remove an unnecessary use of File's internal details. Helps #97.
Remove some unnecessary code and add a comment.
Window shouldn't reach into File internal details. Start reducing this.
Code cleanup tangential to #97.
Further reduce the cases where Window reaches into File's deails.
@rjkroege
Copy link
Owner Author

oops

@codecov
Copy link

codecov bot commented Feb 17, 2019

Codecov Report

Merging #195 into master will increase coverage by 0.26%.
The diff coverage is 17.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
+ Coverage   19.37%   19.63%   +0.26%     
==========================================
  Files          45       45              
  Lines       10261    10209      -52     
==========================================
+ Hits         1988     2005      +17     
+ Misses       8091     8018      -73     
- Partials      182      186       +4
Impacted Files Coverage Δ
elog.go 66.36% <ø> (-0.31%) ⬇️
edit.go 86.78% <0%> (+0.89%) ⬆️
xfid.go 2.25% <0%> (ø) ⬆️
ecmd.go 13.27% <0%> (ø) ⬆️
row.go 4.47% <0%> (ø) ⬆️
acme.go 6.68% <0%> (ø) ⬆️
scrl.go 0% <0%> (ø) ⬆️
col.go 0% <0%> (ø) ⬆️
util.go 22.32% <0%> (+0.1%) ⬆️
wind.go 7.25% <0%> (+0.15%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb2882e...5caa2c4. Read the comment docs.

@rjkroege rjkroege changed the title Rebasing flow Reduce use of File's internal details Feb 17, 2019
@rjkroege rjkroege merged commit 33201e7 into master Feb 17, 2019
@rjkroege rjkroege deleted the rebasing_flow branch March 6, 2019 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant