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

Attempts to fix crash in setMarkedText(_:selectedRange:) #149

Merged
merged 2 commits into from
Aug 25, 2022

Conversation

simonbs
Copy link
Owner

@simonbs simonbs commented Aug 25, 2022

This PR attempts to fix the issue described in #147.

@simonbs simonbs self-assigned this Aug 25, 2022
@simonbs simonbs merged commit 6e7a81c into main Aug 25, 2022
@simonbs simonbs deleted the bugfix/crash-in-setmarkedtext branch August 25, 2022 15:48
@simonbs simonbs mentioned this pull request Aug 25, 2022
simonbs added a commit that referenced this pull request Sep 4, 2022
* Extracts string length to variable

* Uses safe selected range
simonbs added a commit that referenced this pull request Sep 4, 2022
* Updates to tree-sitter 0.20.4

* Adds debug description

* Fixes duplicate matches returned

* Injected languages can now get the language from the text

* Fixes issues in marked text

* Fixes typos

* Improves formatting

* Removes YAML tests

* Enables navigation with marked text

* Fixes off-by-one error in line movement

* Only navigates in marked text for symbols

* Only navigates in marked text for specific symbols

* Improves formatting

* Adds TreeSitterInternalLanguage and TreeSitterInternalQuery

* Updates TreeSitterLanguages

* Revert "Adds TreeSitterInternalLanguage and TreeSitterInternalQuery"

This reverts commit 8b61629.

* Stores strong reference to TreeSitterLanguageProvider

* Makes properties public

* Adds TreeSitterInteralLanguage

* Updates dependencies

* Removes conformance to TreeSitterLanguageProvider

* Adds prepare() to TreeSitterLanguage

* Fixes incomplete sorting implementation

* Fixes tests

* Fixes issue where layoutLines(until:) would attempt to layout beyond string

* Improves code style

* Renames layoutSelection() to layoutLineSelection()

* Improves code style

* Supports converting NSRange to range local or global to line

* Properly renames layoutSelection to layoutLineSelection

* Removes comments

* Improves selection containing line breaks

* Improves code style

* Uses subviews to highlight code

* Clears highlighted views

* Fixes invalid selected range

* Only adjusts selection if start line and end line isn't equal

* Always uses safe location

* Removes debug log

* Renames handleContentSizeUpdateIfNecessary to handleContentSizeUpdateIfNeeded

* Compiles with Xcode 13.3

* Fixes SwiftLint on M1 machines

* Adds overscroll

* Updates Tree-sitter version

* Adds redisplayVisibleLines()

* Fixes crash when redisplaying visible lines

* Adjusts page guide for kerning

* Tap no longer starts editing if scroll view is scrolling

* Improves formatting

* Fixes typo

* Removes unused code

* Prefers breaking long lines at whitespace character

* Fixes spacing in documentation hero

* Fixes lines occurring multiple times

* Improves line wrapping

* Clean up

* Adds link to App Store

* Adds documentation on using a Tree-sitter parser

* Renames CaptureName and CaptureSequence to HighlightName

This is done to be consistent with Tree-sitter's naming.

* Fixes compile error

* Adds Creating a Theme

* Writes 'line-height' instead of 'line height'

* Fixes typo

* Adds Getting Started article

* Adds comments

* Updates list of features

* Update issue templates

* Update README.md

* Update README.md

* Update README.md

* Adds documentation to TextViewDelegate

* Update README.md

* Update README.md

* Improves alt text

* Adds Runestone app icon

* Update README.md

* Immediately stops layouting lines when no line fragments are returned

Previously we would only stop if we had any line fragments. No we always stop. This fixes an isuse where the app would hang when opening large files while line wrapping was disabled.

* Immediately stop layouting lines for zero size viewport

* Fixes incorrect file name (#6)

* Adds groups for TextView's documentation

* Improves documentation of TextView

* Adds more documentation

* Adds documentation to FontTraits

* Fixes typos

* Improves formatting

* Improves formatting

* Overlap check no longer includes upper bounds

* Improves performance of replace(

* Adds moving of lines

* Adds missing SwiftGen file

* Fixes undo/redo for moving lines

* Fixes typo

* Logs unrecognized highlight names (#8)

* Improves formatting

* Renames -layoutLines(untilLocation:) to -layoutLines(toLocation:)

* Fixes formatting

* Fixes formatting

* Removes unused variable

* Improves formatting

* Calculates selection rects faster

* Disables horizontal overscroll when line wrapping is enabled

* Checks against punctuation character set

* Fixes typo

* Does not apply captures with unsupported predicates (#9)

* Uses line break instead of cluster break (#10)

* Adds Tree-sitter submoduel with HTTPS (#12)

* Update README.md

* Fix small typos (#14)

* Update README.md

* Fixes SwiftLint issues (#20)

* Fixes SwiftLint issues

* Fixes compile error

* Removes unsafe build flag from TreeSitter target (#18)

* Removes unsafe build flag from TreeSitter target

* Fixes SwiftLint issues

* Fixes compile error

* Fixes #17

* Removes TreeSitterLanguages dependency from Example project (#22)

* Removes TreeSitterLanguages dependency from Example project

* Ignores all .swiftpm and .build folders

* Renames editorView to scrollView (#23)

* Renames additionalInset to safeAreaInset (#24)

* Renames editorView to scrollView

* Rename additionalInset to safeAreaInset

* Renames maximumLineWidth to constrainingLineWidth (#25)

* Renames editorView to scrollView

* Rename additionalInset to safeAreaInset

* Renames maximumLineWidth to constrainingLineWidth

* Improves comments (#26)

* Fixes issue where setupViewHierarchy() didn't remove all subviews (#27)

* Improves comments

* Fixes issue where setupViewHierarchy() didn't remove all subviews

* Removes unused 'animated' parameter (#29)

* Returns no selection rects when range is empty (#28)

This fixes an issue where the selecting an empty line would scroll to the end of the document

* Ensures caret is visible when moved past horizontal edge (#30)

* Caps scroll offset to minimum and maximum offset (#31)

* Enforces constraining line width (#36)

* Splits example project into Swift packages (#37)

* Splits example project into Swift packages

* Adds READMEs

* Removes tests

* Fixes SwiftLint warnings

* Removes header comment

* Fixes issue where long pressing to select text would scroll (#38)

* Adds support for showing non-breaking spaces (#39)

* Improves text selection (#33)

This is an attempt to fix the issue where typing Korean characters did not work as expected

* Validates predicates of injection captures (#41)

* Uses correct font for line numbers (#44)

Fixes #43

* No longer groups child layers by languages (#45)

* Skip empty captures (#46)

* Enables Catalyst in Example project (#47)

* Fixes crash in compare(_:to:) on Catalyst (#48)

* Update README.md

* Removes debug code (#49)

* Fixes issue where carriage return was not rendered (#52)

* Adds support for specifying line endings (#53)

* Update README.md

* Updates documentation (#54)

* Only prepares text for insertion when caused by external event (#55)

* Considers Windows-style line breaks (\r\n) a composed character sequence (#56)

* Only prepares text for insertion when caused by external event

* Considers Windows-style line breaks (\r\n) a composed character sequence

* Adds tests for custom composed character sequences

* Fixes typu (#57)

* Uses line position to restore selected range when replacing text (#58)

* Makes symbol on line ending public (#59)

* Fixes textInputViewDidChangeSelection(_:) called too early (#61)

* Add isEditable and isSelectable property to TextView (#60)

* Add isEditable property to TextView

Closes #34

* Add isSelectable to TextView

* Add editable and selectable to example menu

* Fixed linting issues

* Fix deselection caret position

* Resigns first responder when editing is disabled

* Clears selected range rather than selecting the first character

* Uses UITextInteractionDelegate to ensure interactions are disabled

* Removes extraneous whitespace to be consistent white styling

* Adds comment

* Elaborates menu item titles

* Only resigns first responder if already editing

* Resigns first responder when disabling selection

Co-authored-by: Simon Støvring <mail@simonbs.dk>

* Fix documentation typos (#62)

* Fix typo in documentation

* Fix typo

* Fix typo

* Create .gitattributes

* Fxies linguist (#63)

* Adds CODEOWNERS (#64)

* Uses byte indices only in -treeSitterLanguageMode(_:bytesAt:) (#65)

* -customRangeOfComposedCharacterSequences(for:) builds upon native range (#66)

* Removes push to main trigger (#67)

* Attempts setting up .spi.yml (#70)

* Adds DocC plugin

* Adds .spi.yml

* Update README.md (#71)

* Only runs Build and Test workflow when source has changed (#72)

* Adds workflow for building example project (#73)

* Update README.md (#74)

* Fixes workflow name (#75)

* Adds workflow_dispatch trigger to all workflows (#76)

* Update README.md (#77)

* Update README.md (#78)

* Don't silently absorb error, at least log it in DEBUG mode (#84)

* Prefer `` when linking to symbols within the package (#83)

Closes #82

This should allow for better copy within Xcode's autocomplete UI to appear in docblocks that previously preferred the `<doc:Link>` style for symbol links.

From Apple's docs:

> When referencing symbols that appear within your Swift framework or package, use symbol links instead. To create a symbol link, wrap the symbol name in a set of double backticks (``).
> In the following example, DocC renders the referenced methods in a monospace font and wraps them in links to the corresponding documentation pages:
>     You can increase the sloth's energy level by asking them to
>     ``eat(_:quantity:)`` or ``sleep(in:for:)``.

See also: https://developer.apple.com/documentation/xcode/formatting-your-documentation-content

* Only set `isPrepared` to true after it really is prepared (#85)

* Fixes issue where caret position is not updated (#86)

When editing the text programmatically the selected range was modified but the updated selection was not reflected.

* Updates caret position after toggling line wrapping (#88)

* Fixes code style in TextInputStringTokenizer (#89)

* Fixes URL

* Uses groupingLevel to check for open group

* Improves handling of caret positioning (#90)

* Scrolls to zero content offset when within text container inset (#91)

* Text view would scroll when editing began (#93)

* Clears cached highlighted rects when changing theme (#94)

* Always insert text when calling `insertText(_:)` programmatically (#87)

* Always insert text when calling `insertText(_:)` programmatically

* Remove trailing white space

* Removes alwaysInsert

Co-authored-by: Simon Støvring <mail@simonbs.dk>

* Allow subclassing TextView and overriding certain methods (#68)

* Allow subclassing TextView and overriding certain methods

Also: Expose the UITextInput interface, add deleteBackward helper

* Fix linter issues

* Make TextView non-final

* Remove `var textInput: UITextInput` in favour of proxy methods

* Remove trailing white space

* Adds UITextInteractions to TextInputView (#95)

* Fixes caret position not updated (#96)

* Fixes issue where long pressing text view to select text would scroll text view (#97)

* Adds Package.resolved (#99)

* Updates parser header (#100)

* Fixes string range out of bounds (#101)

* Exposes more UITextInput functions in TextView (#102)

* Adds implementation of -position(within:farthestIn:)

* Adds implementation of -characterRange(byExtending:in:)

* Adds implementation of -characterRange(at:)

* Adds implementation of -closestPosition(to:within:)

* Adds UITextInput proxy functions

* Updates documentation

* Fixes SwiftLint warning

* 💥 Adds matchMethod to SearchQuery (#104)

* Adds MatchMethod to SearchQuery

* Fixes warnings when building documentation

* Adds Package.resolved (#105)

* Adds Package.resolved

* Fixes Swift toolchain version

* Uses UIMenuEditInteraction on iOS 16 (#92)

* Uses UIMenuEditInteraction on iOS 16

* Fixes SwiftLint warnings

* Fixes shiftLineLeft(_:) and shiftLineRight(_:) reversed (#106)

* Only inserts text once when indenting (#107)

* Removes swift-docc-plugin (#108)

* Updates bottom inset to accommodate for keyboard in Example project (#113)

* Updates bottom inset to accommodate for keyboard

* Fixes SwiftLint warnings

* Updates automatic scroll inset

* Layout lines up to the specified line (#114)

* Notify delegate that the content size has been invalidated (#115)

* Adds Go to Line to example project (#116)

* Supports scrolling to a range of text (#118)

* Adds support for isFindInteractionEnabled (#119)

* Adds find/replace

* Improves code formatting

* Adds isFindInteractionEnabled

* Adds MatchMethod to SearchQuery

* UITextSearching uses MatchMethod

* Adds MatchMethod to SearchQuery

* Fixes warnings when building documentation

* Removes Package.resolved

* Adds customization of highlighted ranges through Theme

* Supports scrolling to a range of text

* Implements scrollRangeToVisible(_:inDocument:)

* Adds documentation

* Fixes SwiftLint warnings

* Fixes compile issues on Xcode 15

* Fixes incorrect range returned from -customRangeOfComposedCharacterSequences(for:) (#121)

* Fixes typo (#123)

* Removes extraneous extension in example project (#125)

* Add support for line break mode in TextView (#124)

* Add a new LineBreakMode type and use it to expose a setting to user to set line break mode. Pass line break mode setting to LayoutManager, LineController and LineTypesetter to look for line breaks using CTTypesetterSuggestClusterBreak instead of CTTypesetterSuggestLineBreak when wrapping lines by character.

* Move let declaration inside the switch statement.

* Move lineBreakMode to a mutable var on LineTypesetter and expose it in LineController. Update this variable when invalidating lines in layout manager, so that line break mode can be changed in existing text views.

* Remove trailing whitespace from lines.

* Update README.md (#126)

* Fixes formatting (#127)

* Disables "Based on dependency analysis" (#128)

* Improves timing when notifying input delegate of selection changes (Thanks Alexander Blach (@blach)!) (#129)

* Renames willBeginEditingFromNonEditableTextInteraction to isPerformingNonEditableTextInteraction

* Removes sendSelectionChangedToTextSelectionView

* Notifies of selection changes in layoutSubviews()

* Disables "Based on dependency analysis"

* Disables SwiftLint warning

* Removes unused code (#133)

* Only redisplays visible lines (#134)

* Support search in a specific range in the text view (#136)

* Support search in a specific range in the text view

* Tweaks documentation of

Co-authored-by: Simon Støvring <mail@simonbs.dk>

* API: convert row/column to offset (#138)

* Fix #137. convert row/column to offset

* 💄

* Renames textLocation(at:) to location(at:)

* Updates documentation of location(at:)

Co-authored-by: Simon Støvring <mail@simonbs.dk>

* Calls super instead of returning true (#139)

* Treats punctuation characters as word boundaries (#140)

* Treats punctuation characters as word boundries

* Fixes SwiftLint warnings

* Updates caret position when setting string (#143)

* Clears undo stack when setting string (#144)

* Sets correct selected range when editing marked text (#145)

* Attempts to fix crash in setMarkedText(_:selectedRange:) (#149)

* Extracts string length to variable

* Uses safe selected range

* Decreases width of caret (#151)

* Places the caret correctly when navigating between lines (#152)

* Adds LineControllerStorage (#150)

* Adds LineControllerStorage

* Fixes SwiftLint warnings

* fix sample code (#154)

* Add FR localization (#155)

* Fixes width of selection rects (#156)

* Fixes width of selection rects

* Removes unneeded variable

* Prevents selected range and marked range from being negative (#157)

* Prevents selected range and marked range from being negative

* Improves comment

* Uses label color as default caret color (#159)

* Fixes incorrect filename (#160)

* WIP tutorials

* Fixes issue where theme was not applied initially (#161)

* Fixes menu not shown correctly on Catalyst (#163)

* LineManager rebuilds tree from string in StringView (#162)

* LineManager rebuilds tree from string in StringView

* Fixes build error

* Locally disables SwiftLint warning

* Updates the DefaultTheme (#164)

* Adds new DefaultTheme

* Uses DefaultTheme in TextViewState if no theme is provided

* Fixes SwiftLint warning

* Makes keywords bold

* Uses correct theme

* Removes theme from 'Adding a Tree-sitter Language' article

* Fixes issues compiling with Xcode 13

* Updates screenshots

* Improves navigation with the keyboard (#153)

* Adds LineControllerStorage

* Fixes SwiftLint warnings

* Decreases width of caret

* Places the caret correctly when navigating between lines

* Removes unused function

* Removes mapping of direction

* Improves code formatting

* Places caret at front of next line fragment when caret is behind last character in line fragment

* Treats line fragments as line endings

* Calls caretRect(at:) on layoutManager instead of self

* Renames shouldNotifyInputDelegateAboutSelectionChangeInLayoutSubviews

* Renames shouldPreserveUndoStackWhenSettingString

* Improves line movement

* Fixes incorrect selection

* Differentiates between line and paragraph

* Removes Ctrl+A and Ctrl+E key commands

* Removes special handling of caret on next line fragment when otherwise after last character

* Supports platform-specific behavior for keyboard navigation

* Fixes SwiftLint warnings

* Introduces shouldMoveCaretToNextLineFragment(forLocation:in:)

* WIP tests

* LineManager rebuilds tree from string in StringView

* Fixes menu not shown correctly on Catalyst

* Fixes build error

* Locally disables SwiftLint warning

* Adds unit tests

* Adds new DefaultTheme

* Uses DefaultTheme in TextViewState if no theme is provided

* Fixes SwiftLint warning

* Makes keywords bold

* Uses correct theme

* Removes theme from 'Adding a Tree-sitter Language' article

* Fixes unit test

* Uses multi-line string

* Fixes SwiftLint warnings

* Fixes page guide color in default theme (#165)

* Improves dark mode colors

* Updates Setting Up a TextView

* Improves dark mode colors (#166)

* Adds section on persisting text

* Reduces file sizes

* Reduces file size

* Adds Tutorials.sketch

* Adds tutorial on supporting syntax highlighting

* Adds missing images

* Adds "Adding a Theme" tutorial

* Adds missing images

* SwiftLint excludes tutorials

Co-authored-by: multigreg <75578022+multigreg@users.noreply.github.com>
Co-authored-by: twodayslate <zac@gorak.us>
Co-authored-by: Andrew Bennet <AndrewBennet@users.noreply.github.com>
Co-authored-by: Adrian Schönig <adrian@schoenig.me>
Co-authored-by: Eli Perkins <eli.j.perkins@gmail.com>
Co-authored-by: Pasi Salenius <pasi@freshbits.fi>
Co-authored-by: Peng Lyu <penlv@microsoft.com>
Co-authored-by: Peng Lyu <penn.lv@gmail.com>
Co-authored-by: Shinolr <wyqbeta+github@gmail.com>
Co-authored-by: William Mead <w1w1_m@icloud.com>
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.

None yet

1 participant