Commit Graph

73 Commits

Author SHA1 Message Date
Kartik K. Agaram f3df1cda0f bugfix: check after cursor on same line when searching upwards 2022-08-11 22:23:16 -07:00
Kartik K. Agaram e85a7e73d0 bugfix: search upwards 2022-08-11 22:23:16 -07:00
Kartik K. Agaram 0afd03e721 bugfix: check before cursor on same line 2022-08-11 22:23:16 -07:00
Kartik K. Agaram da34fabf72 bugfix: pagedown was sometimes bouncing up 2022-08-10 22:56:10 -07:00
Kartik K. Agaram ba48aadaa7 bugfix: backspace from start of final line 2022-08-10 22:38:10 -07:00
Kartik K. Agaram 0218980add click to the left of a line 2022-07-29 14:38:45 -07:00
Kartik K. Agaram 4ce716fe44 line.y -> line_cache.starty in a few more places
Disquieting that none of my tests caught these. On the other hand, I
also haven't noticed any issues in practice. Perhaps cache invalidation
is often unnecessary.
2022-07-27 20:45:46 -07:00
Kartik K. Agaram 3265abacb4 bugfix: skip over drawings when searching 2022-07-25 09:49:26 -07:00
Kartik K. Agaram 0251b3f0c2 bugfix: search
Broken since commit 188bbc73 9 days ago :/ At least we have a test for
it now.
2022-07-21 16:55:05 -07:00
Kartik K. Agaram e2734cd572 bugfix: where cursor is drawn
The published version of lines.love was broken for almost an hour. The
cursor would render one position to the right of where it really is. To
fix it, this commit rolls back 26ba6e4e5a. There doesn't seem a good
way to test it.
2022-07-20 09:11:29 -07:00
Kartik K. Agaram 9f4b41d829 exclude left margin from my word-split heuristic
Gratifying how few tests need changing. Recent commits seem on the right
track.
2022-07-20 07:15:46 -07:00
Kartik K. Agaram a472d218f2 allow Text.nearest_pos_less_than to return 0
This eliminates another case of overflowing margins.
2022-07-20 07:08:28 -07:00
Kartik K. Agaram 26ba6e4e5a unify two similar functions
The cost is just having to tweak a few more brittle tests. I can't
actually perceive any difference in how the cursor moves when I click on
text.
2022-07-19 17:13:16 -07:00
Kartik K. Agaram efd4a8a883 keep text from overflowing right margin
I've been sloppy about this so far, and outside of tests I can't find
any examples where it matters, but it matters in a potential fork where
I'm rendering multiple columns of text.

It's unfortunate that my tests have this level of brittleness. What I'd
really like to assert in many of these changed lines is that the text
stays inside the margins and that more text would overflow margins.
2022-07-19 16:49:08 -07:00
Kartik K. Agaram cc5ab51c53 delete some duplicate initialization 2022-07-19 08:04:21 -07:00
Kartik K. Agaram 82cdd9ddd1 bugfix: couple of margin-relative computations 2022-07-17 22:29:37 -07:00
Kartik K. Agaram 29dac6a6ec separate data structure for each line's cache data
I have no idea what the performance implications of this are..
2022-07-17 21:05:01 -07:00
Kartik K. Agaram f61d4269f5 bring back a set of constants
It's starting to sink in that I don't want hard-coded constants inside
objects.
2022-07-16 08:48:02 -07:00
Kartik K. Agaram c26b377ab3 more decoupling editor tests from App 2022-07-16 08:33:05 -07:00
Kartik K. Agaram a2b654b534 more decoupling editor tests from App 2022-07-16 08:27:11 -07:00
Kartik K. Agaram 2884f872d8 make test initializations a little more obvious 2022-07-15 22:12:25 -07:00
Kartik K. Agaram 3b36093553 left/right margin -> left/right coordinates
Editor state initialization now depends on window dimensions, so we have
to more carefully orchestrate startup.
2022-07-12 20:54:50 -07:00
Kartik K. Agaram 92ad99853e call edit rather than App callbacks in tests 2022-07-12 15:41:17 -07:00
Kartik K. Agaram 81ecca89ff start passing in Editor_state explicitly
In this commit, top-level edit functions:
  - edit.draw
  - edit.update
  - edit.quit
  - edit.mouse_pressed
  - edit.mouse_released
  - edit.textinput
  - edit.keychord_pressed
  - edit.key_released
2022-07-12 15:33:06 -07:00
Kartik K. Agaram e95b4fec12 initialize contains test state 2022-07-12 15:29:22 -07:00
Kartik K. Agaram 8bbc1ffe34 group all editor globals
We're still accessing them through a global. But we'll change that next.
2022-07-12 15:24:56 -07:00
Kartik K. Agaram 9b49c8da77 start decoupling editor tests from App 2022-07-11 23:18:26 -07:00
Kartik K. Agaram 6c4483976e skip multiple consecutive whitespace 2022-07-11 19:18:54 -07:00
Kartik K. Agaram bc2c14c899 support other whitespace chars in word movements 2022-07-11 18:56:19 -07:00
Kartik K. Agaram 92e572fc89 flesh out some tests for word movements 2022-07-11 18:46:49 -07:00
Kartik K. Agaram 6dfe954c02 yet another bugfix in selection management
Thanks Leonard Schütz for the report!

Failing scenario:
  click to move cursor
  hit backspace

First backspace wasn't being doing anything earlier.
2022-07-07 07:39:01 -07:00
Kartik K. Agaram 914d9c6f98 bugfix: clicking on empty lines 2022-07-01 12:16:43 -07:00
Kartik K. Agaram 429a42eb1c right margin 2022-06-30 22:54:34 -07:00
Kartik K. Agaram 8c7bea8f76 rip out notion of Line_width 2022-06-30 19:50:27 -07:00
Kartik K. Agaram 510b0d1dc3 bugfix: lines that aren't drawn from the start
I can't believe I didn't catch this until now. All I had to do is open
MobyDick.markdown from https://www.hogbaysoftware.com/posts/moby-dick-workout,
press page-down and click on the top screen line (or any screen line
containing the same line as the top screen line). Easy to catch with any
file containing lots of overly long lines, as happens in particular at
the start of Moby Dick.

I _had_ seen this problem before, but it seemed to disappear after
unrelated changes, and I convinced myself I'd fixed it as a side-effect.
The bug just failed to manifest if the top line happened to start at the
top of the screen. Scroll down a few pages in Moby Dick and the dialogue
starts and line length drops precipitously.
2022-06-30 18:14:48 -07:00
Kartik K. Agaram 98fa46bf99 some redundant calls 2022-06-30 17:44:31 -07:00
Kartik K. Agaram ea4aa0999c clicking to the right of a line within line width 2022-06-29 09:30:23 -07:00
Kartik K. Agaram 8d3adfa36d bugfix: clicking past end of screen line
I could swear I checked this at some point. But I didn't have a test!
2022-06-29 09:17:38 -07:00
Kartik K. Agaram b49ff8dde9 bugfix: scrolling in left/right movements
I'd always had a funny feeling there was something missing there but
somehow never thought of the right failing test.
2022-06-28 18:48:59 -07:00
Kartik K. Agaram 83ba9e61d1 bugfix: typing a capital letter deletes selection 2022-06-26 17:07:27 -07:00
Kartik K. Agaram 44fb3ecd55 bugfix: deleting a selection spanning pages 2022-06-26 16:34:06 -07:00
Kartik K. Agaram 84875f3c43 bugfix: don't delete selection when moving cursor 2022-06-23 12:05:36 -07:00
Kartik K. Agaram 515dad95f9 keep drawings within the line width slider as well 2022-06-22 21:08:17 -07:00
Kartik K. Agaram 8e68c699f5 bugfix: delete selection before pasting 2022-06-21 09:56:04 -07:00
Kartik K. Agaram 0d1e6aacd9 revert selection logic to before commit 3ffc2ed8f
We still have a failing test, but now it's the one we introduced in
commit 3ffc2ed8f.
2022-06-20 13:12:29 -07:00
Kartik K. Agaram 978c143397 snapshot: test for a new regression
Caused by commit 3ffc2ed8f.

We might need to bring back a lot of complexity for this.
2022-06-20 12:12:09 -07:00
Kartik K. Agaram 7508a70ed5 selection bugfix 2022-06-20 12:02:51 -07:00
Kartik K. Agaram 3986e99fe0 no, that's not right
Bugfix: we want selections to persist even when we lift up the shift
key.

This requires hoisting some code inside every case inside the whole
keypress hierarchy, to ensure we never clear selections before
textinput events can handle them.

Current cross-cutting concerns we're explicitly scattering code for.
  - autosave
  - undo
  - selection management
2022-06-20 11:31:14 -07:00
Kartik K. Agaram 3be413602a bugfix: typing should delete highlighted text
The test harness now also mimics real usage more precisely.
2022-06-20 10:48:35 -07:00
Kartik K. Agaram 3ffc2ed8f3 bugfix
To reproduce:
  click to position cursor at end of a line
  hit enter
  press any key

before:
  newline got erased and key got added to previous line

now:
  newline is preserved

The new test checks a generalization of this.
2022-06-19 09:21:32 -07:00