Commit Graph

370 Commits

Author SHA1 Message Date
Wliu
7e0635d2c0 Fix spec 2018-01-26 18:41:57 -05:00
Wliu
be24e6edf7 Revert change to move mouse cursor on right-click 2018-01-24 11:22:41 -05:00
David Wilson
6d09a5257a Fix #16538: Middle-click pastes into read only editor on Linux
This change fixes an issue where users on Linux are able to paste into
read only TextEditors by clicking the middle mouse button.  The fix is
to check for whether the TextEditorComponent's isInputEnabled method
returns true before pasting with middle click on Linux.
2018-01-22 18:50:07 -08:00
Antonio Scandurra
3fbfadde5a Don't break subpixel AA when cursor is at the end of longest line
With the Electron upgrade, something changed in the way characters are
rendered/measured, and that was causing subpixel anti-aliasing to stop
working when cursors were at the end of the longest line.

Every cursor has a width that is calculated in the following way:

* If there's a character after the cursor, the width corresponds to
width of such character.
* Otherwise, the width equals to the "base character width" measured on
a dummy line.

In the latter case, even if we were setting the width of the content
container to account for the width of such cursor, some rounding problem
was causing the cursor to be able to escape the container and thus break
subpixel anti-aliasing.

With this commit, instead of rounding the value we assign to the
container width, we will always ceil it. This ensures that cursors are
always strictly contained within the parent element and resolves the
subpixel anti-aliasing issue.
2018-01-19 11:20:53 +01:00
Antonio Scandurra
c48ba79f3c Prevent selection of non-text content in editor
Signed-off-by: Nathan Sobo <nathan@github.com>
2018-01-09 15:16:17 +01:00
Antonio Scandurra
3d21ac0742 Render highlights behind lines
This fixes a bug most likely introduced with #16511 by ensuring that UI
elements (such as selections) never cover up the text.

Signed-off-by: Nathan Sobo <nathan@github.com>
2018-01-09 15:15:54 +01:00
Nathan Sobo
4926fe466c Move highlights container into lines for theme compatibility 2018-01-08 13:16:46 -07:00
Jason Rudolph
408070e913 Set the tabIndex on the input element
This commit reverts a portion of the changes introduced in
9eac520e6a. Prior to that commit, we were
setting the tabIndex to -1 on the atom-text-editor element. This commit
restores that behavior.

Instead of setting a custom tab index directly on the atom-text-editor
element, we instead set the tabIndex on the input element *inside* the
atom-text-editor element.

With these changes in place, you can successfully use the tabIndex to
define the tab order for atom-text-editor elements. 😅
2018-01-04 14:31:11 -05:00
itsmichaelwang
e462d0d298 Fix lint issue 2018-01-04 14:23:12 -05:00
itsmichaelwang
9eac520e6a Allow you to tab through modal text box 2018-01-04 14:23:12 -05:00
Antonio Scandurra
69799d35b2 Delete Chrome 56 workarounds 2017-12-22 14:44:17 +01:00
Antonio Scandurra
8b3c3bcfcf Loosen containment rules on dummy scrollbar elements
This commit uses `content` containment (i.e. `layout paint style`) as
opposed to `strict` containment (i.e. `layout paint style size`) for
dummy scrollbar elements.

By removing `size` containment we are fixing a rendering bug that was
preventing the scrollbar from being sized correctly. This problem was
caught by a TextEditorComponent test
(https://circleci.com/gh/atom/atom/6393).
2017-12-22 14:29:22 +01:00
Wliu
1d6549a8e3 Merge pull request #16328 from atom/wl-right-click-selections
Update auxiliary click logic for moving cursors
2017-12-21 12:18:41 -05:00
Katrina Uychaco
2d6750cae3 Remove input enabled check for 'is-focused' class
vim-mode-plus relies on this behavior
2017-12-14 11:56:23 +01:00
Wliu
db392502e4 Always move the cursor on middle-click 2017-12-05 23:54:43 +01:00
Wliu
69214dc26a On clicks, only move cursor if there is one cursor without a selection 2017-12-05 23:11:45 +01:00
Katrina Uychaco
a993742f7f 👕 🔥 semicolon 2017-11-28 22:06:33 -08:00
Katrina Uychaco
aeb9af63df Store readOnly state on the TextEditor model 2017-11-28 21:14:40 -08:00
Katrina Uychaco
909caa2a59 Add 'readonly' attribute to <atom-text-editor> element 2017-11-28 20:01:31 -08:00
Wliu
3569a11574 Rework didMouseDownOnContent to always position cursor 2017-11-15 12:42:27 +01:00
Linus Eriksson
77c685a1b7 Use wheelDelta instead of delta
In Atom 1.19 we changed the scroll handler to use deltaX and deltaY
instead of wheelDeltaX/wheelDeltaY. wheelDelta is larger so this caused
the scrolling speed to slow down. This change in speed was especially
noticable on Linux
2017-11-06 22:50:53 +01:00
Justin Ratner
7639afe684 Judge resize of overlay by contentRect changing 2017-11-02 15:13:49 -06:00
Nathan Sobo
f25570f135 Exclude Shift from keydown events that terminate selection drags 2017-11-01 14:00:43 -06:00
Nathan Sobo
11511f27d5 Don't terminate selection dragging when a modifier key is pressed
This preserves the ability to add selections via ctrl- or cmd-click.
2017-11-01 09:22:38 -06:00
Nathan Sobo
252a98b231 Prevent the browser from auto-scrolling the scroll container on spacebar 2017-10-31 13:55:40 -06:00
Max Brunsfeld
482824047c ⬆️ text-buffer 2017-10-30 17:26:21 -07:00
Nathan Sobo
5779111799 Use destroyFoldsContainingBufferPosition in more cases 2017-10-25 12:50:56 -06:00
Justin Ratner
089717cbd3 fix failing test 2017-10-20 15:46:27 -06:00
Justin Ratner
d0bdbb861b update overlay itself instead of text editor when resize occurs 2017-10-20 11:30:50 -06:00
Antonio Scandurra
65af9e953b Stop dragging only when user interacts with keyboard
Previously, we used to prevent the user from dragging the selection
further when the buffer was about to change. This was problematic
because any change in the buffer, even one that was performed
"automatically" by a package, would cancel the dragging action and
result in a confusing experience for the user.

On the other hand, we want to prevent users from accidentally selecting
text when they perform an edit (see #15217, #15405).

This commit addresses both concerns by canceling the dragging as soon as
the user interacts with the keyboard, instead of canceling the dragging
when the buffer is about to change.

One downside of this approach is that it changes the behavior of
pressing a keystroke that does not result in a buffer change, e.g.
Shift, Arrow Keys, etc.

Signed-off-by: Jason Rudolph <jasonrudolph@github.com>
2017-10-17 18:50:20 +02:00
Justin Ratner
0c35c26805 fix infinite overlay resizing loop 2017-10-14 19:05:54 -06:00
Antonio Scandurra
7853e3cd8c Don't throw when destroying block decorations inside marker change event 2017-10-11 09:42:53 +02:00
Antonio Scandurra
683cdeac27 Always revert to composition checkpoint, even if input is disabled
Previously, if the user opened the IME menu while input was disabled, we
would create a composition checkpoint without reverting to it after the
composition ended. When enabling input again, the first keystroke would
cause any buffer change that occurred between the IME composition and
the keystroke to be reverted.

With this commit we will always revert and delete the composition
checkpoint as soon as the composition ends, regardless of whether the
input is enabled or not.
2017-10-06 13:34:16 +02:00
Nathan Sobo
835efd3d68 Clear the dimensions cache after updating the soft wrap column
Updating the soft wrap column could cause us to compute different values
for derived dimensions, so any dimensions that were cached *in the
process* of updating the soft wrap column need to be cleared.
2017-10-05 15:47:59 -06:00
Antonio Scandurra
f640e9339d Make comment more succinct
Signed-off-by: Nathan Sobo <nathan@github.com>
2017-10-05 18:54:26 +02:00
Antonio Scandurra
8759f9dac7 Clear dimensions cache when approximate screen line count changes 2017-10-05 13:51:23 +02:00
Nathan Sobo
293b52d797 Fix rendering bug when folds hide the vertical scrollbar w/ soft wrap on 2017-10-03 11:09:44 -06:00
Matthew Dapena-Tretter
eb46d0a5c6 Fix mouseup listener cleanup when dragging in text editor 2017-09-29 14:34:43 -07:00
Wliu
1a4e6c4c85 Merge pull request #15603 from jsoref/spelling
Spelling
2017-09-10 18:29:38 +02:00
Josh Soref
cb3fb74d6b spelling: horizontal 2017-09-10 15:46:39 +00:00
Josh Soref
cbc4823cde spelling: combinations 2017-09-10 15:46:38 +00:00
Antonio Scandurra
c1981ffb44 Correctly remove block decorations whose markers have been destroyed
In https://github.com/atom/atom/pull/15503 we mistakenly assumed
`marker.isValid` accounted only for the validity of the marker. However,
that method returns `false` also for markers that are valid but have
been destroyed. As a result, the editor component was mistakenly not
removing block decorations associated with such markers.

With this commit we will rely on the local `wasValid` variable instead.
If its value is `true`, it means that the block decoration has been
accounted for in the `lineTopIndex` and must, as a result, be cleaned up
in case the marker or the decoration gets destroyed.
2017-09-07 17:52:04 +02:00
Antonio Scandurra
4b3fa34d4e Merge pull request #15580 from atom/as-update-scrollbars-on-detach-reattach
Flush scroll position to dummy scrollbar components on re-attach
2017-09-07 16:39:16 +02:00
Antonio Scandurra
806b652da4 Flush scroll position to dummy scrollbar components on re-attach
This prevents the dummy scrollbars from resetting their position to `0`
when the editor element is moved elsewhere in the DOM (e.g. when
splitting a pane item).
2017-09-07 15:05:42 +02:00
Indrek Ardel
499ef16013 Default re-used element class name to empty string 2017-09-07 14:48:35 +03:00
Antonio Scandurra
7bd2c670e1 Merge pull request #15546 from atom/as-never-autoscroll-when-clicking-on-content
Don't autoscroll when using the mouse to add, delete or move selections
2017-09-06 02:12:15 -07:00
Antonio Scandurra
20ea98ad41 Don't render block decorations located outside the visible range
Previously, when trying to use block decorations on non-empty markers,
Atom could sometimes throw an error if such markers ended or started at
a position that was not currently rendered.

In fact, even if we already restricted the decoration query to markers
that intersected the visible row range, markers that were only partially
visible would still be considered for rendering. If, depending on the
`reversed` property, we decided to render the tail or head of the marker
in question and this was outside the viewport, Atom would throw the
aforementioned exception.

This commit addresses the above issue by explicitly ignoring block
decorations that are located on rows that are not yet rendered.
2017-09-05 18:05:35 +02:00
Antonio Scandurra
91bb1e12c7 Don't autoscroll when using the mouse to add, delete or move selections 2017-09-05 15:26:54 +02:00
Antonio Scandurra
6e919e7acd Don't remeasure invalid block decorations
This fixes an uncaught exception that was being thrown after
invalidating a marker and resizing the editor.
2017-09-02 11:11:27 +02:00
Antonio Scandurra
53135c5d0d Call this.didMouseDown instead of props.didMouseDown in dummy scrollbars 2017-08-31 14:23:11 +02:00