Commit Graph

8041 Commits

Author SHA1 Message Date
Linus Eriksson
27f17318d7 Don't attempt to move undefined items when splitting panes 2017-08-24 16:15:06 +02:00
Antonio Scandurra
e6b84dbb44 Test handleMouseDragUntilMouseUp 2017-08-22 14:38:05 +02:00
Nathan Sobo
5eae5ed5eb Merge pull request #15392 from atom/fb-wb-standard-env
Use standard (eslint's) 'env' field over globals
2017-08-21 09:38:34 -06:00
Nathan Sobo
08f36de7ec Merge pull request #15394 from atom/fb-wb-command-registry-js
Convert CommandRegistry to JavaScript
2017-08-21 09:35:31 -06:00
Antonio Scandurra
2f46b8e00e Put back mistakenly deleted line 2017-08-21 09:53:54 +02:00
Will Binns-Smith
ac32ffb155 Convert CommandRegistry to JavaScript
This was bootstrapped with running `decaffeinate` on both command-registry
and its spec, but involved a line-by-line eyeing and updating for idioms
and, in one case, correctness:

For some reason, copying the keys to the new dispatchedEvent in
coffeescript (command-registry.coffee:235) currently does not result in a thrown
exception, as it should when trying to write over the read-only property
`isTrusted`, so I added a check to ensure that the key did not already
exist in the new event. Moreover, other definitions of `preventDefault`,
`stopPropagation` and friends, which are also enumerable afaict, would
also overwrite the ones defined just prior (command-registry.coffee:220
and command-registry.js:325), so that check ensures we don't overwrite
those either.

Test plan: `./script/lint && ./script/test`, and a lengthy smoke test of
various commands through keybindings, command palette, and package
interfaces.

Released under CC0.
2017-08-20 20:52:43 -07:00
Will Binns-Smith
882a1924f0 Remove one-off eslint global pragmas in favor of envs 2017-08-20 19:55:00 -07:00
Nathan Sobo
3d0d1ae44e Prevent block decoration margins from collapsing during measurement
We now render a 1px high sentinel element between off-screen block
decorations before measuring them to prevent margins from collapsing.
2017-08-20 08:23:41 -06:00
Nathan Sobo
835ed10f7c Handle highlight end rows with 'before' blocks in addition to 'after' 2017-08-20 07:32:44 -06:00
Nathan Sobo
f33051da33 Fix highlight end pixel position calculation
Previously, we were calculating the position preceding block decorations
for the row following the end of the highlighted range, but that's
actually wrong. We just want the position following block decorations of
the end of the highlighted range, plus one line height. This prevents us
from incorrectly rendering the end of highlight after block decorations
that immediately follow the end of the highlighted range.
2017-08-20 07:00:50 -06:00
Antonio Scandurra
effc6d9d21 Fix line number position when block decorations are at tile boundaries
When there are block decorations, we compute a `marginTop` style for
line numbers, so that they can be aligned correctly to the corresponding
line nodes.

This commit fixes a regression in the logic that calculated the
`marginTop` value, which was failing to correctly render line numbers
when block decorations were located right before the end of a tile, or
exactly at
the beginning of it.
2017-08-19 15:40:32 +02:00
Ash Wilson
962bbd509a Merge pull request #15377 from atom/aw-async-watchpath
Async watchPath method
2017-08-18 15:51:44 -04:00
Ash Wilson
e7fcb0d079 Adjust Project root directory watching to account for async watchers 2017-08-18 09:10:20 -04:00
Nathan Sobo
44f3cf73ea Merge pull request #15374 from atom/ku-save-as-default-dir
Don't assign default path for `showSaveDialog` unless it exists
2017-08-18 06:58:29 -06:00
Ash Wilson
aa26eba678 Jasmine, not Mocha 2017-08-17 22:01:25 -04:00
Ash Wilson
6ffb3f3ff2 Test first 2017-08-17 21:59:32 -04:00
Katrina Uychaco
ff80e5905c Don't assign default path unless it exists 2017-08-17 12:20:04 -07:00
Nathan Sobo
e80658081a Merge pull request #15327 from captbaritone/accel-2
Base context menu accelerators on activeElement
2017-08-17 09:19:10 -06:00
Nathan Sobo
927fa3c9cb Merge pull request #15367 from atom/as-fix-scrollbar-visibility
Set visibility: hidden on dummy scrollbars if native ones are invisible
2017-08-17 09:17:30 -06:00
Nathan Sobo
6c20d6199f Merge pull request #15359 from atom/as-fix-folding
Fix folding for lines that contain a comment
2017-08-17 09:15:39 -06:00
Antonio Scandurra
1ffc8997d2 Set visibility: hidden on dummy scrollbars if native ones are invisible
This prevents the cursor from unexpectedly changing when approaching the
bottom/right corner of the editor with the mouse, even when no scrollbar
is being shown.
2017-08-17 15:11:32 +02:00
Antonio Scandurra
c99ac52152 Fix folding for lines that contain a comment
In attempting to optimize the performance of `isFoldableAtBufferRow` in
3c87b74, we mistakenly introduced a bug that caused lines that contained
a comment but didn't start with one to not be foldable anymore.

With this commit we are restoring the previous behavior, thus only
disabling folding for lines that start with a comment (ignoring leading
whitespaces).
2017-08-17 14:28:30 +02:00
Antonio Scandurra
1b5ed62e4f Ignore scroll requests to NaN, null or undefined positions 2017-08-17 09:17:52 +02:00
Nathan Sobo
9cf7f609f5 Round return values of getMaxScrollTop/Left 2017-08-16 15:59:04 -06:00
Nathan Sobo
72322985d9 Merge pull request #15337 from atom/ns-remeasure-longest-line
Remeasure the longest line's width when the font size changes
2017-08-16 14:32:22 -06:00
Jordan Eldredge
228f65da5f Base context menu accelerators on activeElement
Addresses issue pointed by out @nathansobo in #15277 where keybindings
for unfocusable nodes were being surfaced as accelerator indicators in
context menus.

When you right click in the DOM, your focus goes to the first focusable
ancestor of your click target. This change uses the ancestor that you
are actually focused on when looking for avaliable key bindings rather
than using the event target directly. This ensures that any surfaced key
bindings are actually reachable.
2017-08-16 11:58:05 -07:00
Nathan Sobo
2bcfd934c0 Fix tests by ignoring off screen lines
Also, clear the dataset when recycling DOM elements

Signed-off-by: Antonio Scandurra <as-cii@github.com>
2017-08-16 12:31:42 -06:00
Antonio Scandurra
15e3fbaa07 Merge pull request #15339 from atom/ns-as-clear-lines-to-measure-later
Only clear linesToMeasure when we have actually measured
2017-08-16 20:08:59 +02:00
Nathan Sobo
9d356020c5 Remeasure the longest line's width when the font size changes 2017-08-16 11:53:55 -06:00
Nathan Sobo
c626836b2e Only clear linesToMeasure when we have actually measured
Previously, as soon as we decided to render linesToMeasure, we would
clear them out. However, if a second update interleaved with the update
that initially requested measurement, it could cause the requested lines
to not be present when the measurement phase from the first update
occurred. Now, any additional updates will only add to the set of lines
that need to be measured until the measurement phase actually happens.

Signed-off-by: Antonio Scandurra <as-cii@github.com>
2017-08-16 11:28:58 -06:00
Nathan Sobo
c398fe66c9 Hide off-screen lines when we render them for measurement 2017-08-16 10:00:57 -06:00
Nathan Sobo
e9a00ce9b3 Merge pull request #15324 from atom/ns-fix-mousewheel-handling
Only scroll one axis at a time, whichever has the greater delta
2017-08-15 19:29:36 -06:00
Nathan Sobo
4493ae2270 Only scroll one axis at a time, whichever has the greater delta 2017-08-15 16:08:07 -06:00
Nathan Sobo
b35708b8cf Add test for placeholder text positioning 2017-08-15 15:48:18 -06:00
Nathan Sobo
586b818bae Merge pull request #15317 from atom/as-fix-wrong-measurements
Move cursors container inside lines container
2017-08-15 11:38:54 -06:00
Antonio Scandurra
3d71e627eb Move cursors container inside lines container
This will ensure that applying any style that changes the location of
the lines container will also correctly position the cursors.
2017-08-15 18:44:23 +02:00
Nathan Sobo
8e6497bfba Merge pull request #15277 from captbaritone/accel
Add accelerator indicators to context menus
2017-08-15 10:40:35 -06:00
Nathan Sobo
7226f6fb08 Merge pull request #15313 from atom/as-fix-extra-schedule-update
Ensure extra document updates are not scheduled during `updateSync`
2017-08-15 09:01:22 -06:00
Antonio Scandurra
f569514938 Ensure extra document updates are not scheduled during updateSync
When changing the editor styles, we force the component to remeasure
character dimensions. If they change, each line's height could change
too, causing the current scroll top position to not match the viewport
the user was observing. Thus, when detecting a line height change, we
try to show users the area of the screen they were looking prior to
tweaking the font size.

In trying to maintain the aforementioned logical position, however, we
were mistakenly scheduling a new update before actually finishing the
current one. This was problematic because if the first update detected
that the longest screen line changed and such line was off-screen, it
would try to render it. Before having the chance to measure it, though,
the new update would kick in and delete the new longest screen line
node, because it assumed it had already been measured. Finally, when
`measureContentDuringUpdateSync` fired, it would notice that the longest
screen line node did not exist and throw an exception as a result.

This commit changes the `updateSync` method to set the `updateScheduled`
flag only before returning control to the caller, as opposed to doing so
at the beginning. This prevents calls to `scheduleUpdate` made in
`updateSync` from scheduling new unwanted updates.
2017-08-15 15:32:29 +02:00
Antonio Scandurra
e980598aba Honor editor's scrollSensitivity parameter 2017-08-15 12:22:59 +02:00
Nathan Sobo
433c514673 Always render hidden input
This avoids mysterious timing issues in which the editor gets a 'focus'
event in a state where `isVisible` returns false. If we always render
the hidden input, we can always focus it.

Signed-off-by: Antonio Scandurra <as-cii@github.com>
2017-08-14 11:53:02 -06:00
Nathan Sobo
2f2d62ca51 Merge pull request #15296 from atom/as-fix-cancel-dialog-on-quit-or-restart
Prompt user only once when quitting/restarting and canceling save dialog
2017-08-14 09:04:04 -06:00
Antonio Scandurra
eb1eeb3fde Ignore clicks on block decorations
Previously, clicking on a block decoration to interact with it would
cause the editor to scroll to the line next to it. This is inconvenient,
especially if the decoration was designed to be interactive and
contained buttons or links. If the decoration was close to the bottom of
the screen, clicking on a button inside of it would make the editor
scroll down and abort the click.

This behavior regressed during the editor rendering layer rewrite and
with this commit we are restoring the original behavior by simply
ignoring clicks that land on block decorations.
2017-08-14 15:43:48 +02:00
Antonio Scandurra
e50a73b033 Fix tests 2017-08-14 12:28:19 +02:00
Antonio Scandurra
91b7c14281 Prompt user only once when quitting/restarting and canceling save dialog
I think this slipped through during the refactoring performed in
dc32018. With this commit we are fixing the regression and adding a new
main process regression test to exercise this behavior.
2017-08-14 12:21:19 +02:00
Jordan Eldredge
e71d8d863c Add accelerator indicators to context menus
Electron allows us to pass an "accelerator" property for each menu item, which
is renders to the right of the menu item. We were already adding these for the
application level menus.

This pull request adds the accelerator property to regular context menu items,
which should make it easier for people to discover/recall key mappings for
actions which they usually take via a context menu.
2017-08-12 15:00:44 -07:00
Max Brunsfeld
acc7b97ae0 Merge pull request #15264 from captbaritone/pane-destroy-item
Ensure Pane.destroyItem always returns a promise
2017-08-12 13:04:35 -07:00
Nathan Sobo
ff32fd80bf Merge pull request #15273 from atom/as-fix-line-height-0
Don't throw an error when setting an incredibly small `lineHeight`
2017-08-12 13:46:23 -06:00
Nathan Sobo
feb0cddf5e Merge pull request #15265 from atom/ns-ime-workaround
Work around incorrect data on `compositionupdate` events in Chrome 56
2017-08-12 13:26:01 -06:00
Antonio Scandurra
964f209c40 Don't throw an error when setting an incredibly small lineHeight
Instead, if the measured line height equals 0, default it to 1 so that
the editor component doesn't start computing `NaN` or `Infinity` values
due to e.g. dividing by 0.

We should probably consider sanitizing line heights smaller than a
certain threshold, but that's non trivial because line height is
expressed as a multiplier of the font size. Also, users may style the
`line-height` property via CSS, which may still throw errors when using
small values.
2017-08-12 15:38:32 +02:00