Commit graph

13 commits

Author SHA1 Message Date
Jeremy Soller
3c94352f3f Support expanding tabs 2024-06-10 08:12:42 -06:00
Jeremy Soller
896f36cdab Embed font for wrap_word_fallback test 2024-06-06 19:38:40 -06:00
Joshua Megnauth
ff5501d9a3
Fix: Undo and redo correctly updates editor modified status (#244)
* Set an index for the last saved change

I added an index that represents the last saved change.

Editors are considered to be unsaved or modified if the current change
is different from the save index. In other words, if the last saved
change is `5`, undoing or redoing past that change should indicate that
the editor has been modified.

This is needed to fix two bugs in COSMIC Edit:
* https://github.com/pop-os/cosmic-edit/issues/116
* https://github.com/pop-os/cosmic-edit/issues/128

* Unit test that confirms pivot logic works

I'll most likely simplify the API as end users don't have a way to
cleanly use `Pivot::Exact` without access to the internal command
buffer.

* Simplify save point API

* Implement more save point unit tests

A unit test for an edge case currently fails but normal usage works.

* Fix edge case for empty command index and pivot

* More save point unit tests for common use cases
2024-03-25 08:55:44 -06:00
dtzxporter
be471833c9 Add a test case for extra line insertion. 2024-02-02 12:53:48 -07:00
Jeremy Soller
ceb6dccb40
Update test image size 2024-02-02 10:50:17 -07:00
Jeremy Soller
dd2c907f4e
Update test images 2024-02-02 10:48:57 -07:00
dtzxporter
cc75bb66b4 Adds a separate wrapping option to allow word to glyph fallback. 2024-02-02 10:40:30 -07:00
dtzxporter
b7f150615d Add a test for word wrapping fallback. 2024-02-02 10:40:30 -07:00
dtzxporter
e83f55bfeb Re-generate word tests so they don't wrap because that's not what they are testing. 2024-02-02 10:40:30 -07:00
Jeremy Soller
8457e68d98 Fix tests 2024-01-17 13:31:03 -07:00
Jeremy Soller
d0b4b4635e Refactor of scroll and shaping
- Scroll is identified by line index and layout index, instead of just
  layout index
- Shaping has the option to prune, where caches outside of the scroll
  view are cleared
- Syntax editor no longer requires layout of all lines, only of lines
  inside scroll
- BufferLine has a metadata field that can be used by other abstractions
  to know when text was changed
2024-01-17 13:31:03 -07:00
Dov Reshef
8db03fe3cf Add image render tests
Add tests that will match rendered words/paragraphs against reference
images.

Use env var `GENERATE_IMAGES` to write the initial reference images to
the repository.
2023-09-27 11:57:18 +03:00
Imbris
91674d5a49 Fix #134 and include a test for it.
Try to ensure that using "the width computed during an unconstrained
layout" as the width constraint during a relayout produces the same
layout. This is useful for certain UI layout algorithms.

See https://github.com/pop-os/cosmic-text/issues/134

* Instead of computing the LayoutLine width from the positioned and
  aligned glyphs, we pass through width computed during line wrapping
  (unless justified alignment is used, in this case we use the old
  approach because the use case for measuring the width isn't really
  applicable to justified text since that will just expand to the
  provided width). For the produced width to later give the same
  wrapping results when passed in as the `line_width` it needs to use
  the same exact float arithmatic that was used to compute the width
  that is compared against `line_width` when making line wrapping
  choices. Passing this width through as the LayoutLine width is the
  most covenient option without making more major changse to the API.
  Nevertheless, I am imagining that if we get a dedicated measurement
  method (i.e. that doesn't do the final positioning and alignment of
  glyphs and which caches `Vec<VisualLine>`), then this width can just
  be exposed there instead of preservering it in LayoutLine.
* Incidentally, this fixes
  https://github.com/pop-os/cosmic-text/issues/169.
* Switch substraction from `fit_x` to checking whether potential
  addition to the current line width would exceed the `line_width`. This
  avoids the float error being dependent on the provided `line_width`
  value.
* When eliminating trailing space from the line width, we avoid
  backtracking with subtraction (which would not give the same exact
  value due to float error) and instead save the previous width and use
  that.
* If the previous word did not exceed the line_width, we now include a
  single blank word even if it would cross the width limit since its
  width won't be counted. This is necessary to get the same wrapping
  behavior when re-using the measured width (which doesn't count a
  single trailing blank word). Note, this whitespace logic may be
  reworked anyway if <https://github.com/pop-os/cosmic-text/issues/155>
  is addressed.
* Change tests to use `opt-level=1` to keep test runtime down.
* Add `fonts` folder for fonts used in tests.
* Fix an issue where a non-breaking whitespace was assumed to be the
  start of a section of spaces which included characters that weren't
  even whitespace.
* Add some TODOs about incongruencies between `is_whitespace`,
  justification, and line breaks.
2023-08-25 21:00:46 -04:00