For an unknown reason, process termination requires write-intent read action. Previously the write-intent lock was acquired on a background thread, which interfered with active modal progresses. Now we dispatch process termination to EDT. We hope that process termination does not require write action
(cherry picked from commit be5b8bc9e69b97b957ee9a1fd3ef8fa8e85d0ddf)
IJ-CR-165004
GitOrigin-RevId: b3182bb3682141e81775306130f540af449dd5e3
The font size can be reset for many reasons, and it's not easy
to track them all from a listener. But if it's reset, we almost
never need a zoom indicator. On the other hand, if it's explicitly
set to any value, the zoom indicator is almost always useful.
So it seems like a good approximation to determine
whether we need it or not.
Pass a boolean flag to listeners so they can decide whether
a zoom indicator is needed. We don't have this zoom
in execution-impl, so there it doesn't matter what we pass.
(cherry picked from commit eebc12f64d0aed8f5d8a39e1606193c5b704ad5b)
IJ-CR-162754
GitOrigin-RevId: 1a5ac1d6a7c88ad4626f27713f9e3934b97ed48f
But if there is no shell integration, the heuristic-based approach will be used.
(cherry picked from commit c8c1a3b33f0f83eb1c7dc6a61c78197b1a0fe780)
IJ-CR-162752
GitOrigin-RevId: 4bfdce78fef241baf7b07308472db1396c158807
For now, it is only the initial value. Updating will be implemented in the next changes.
(cherry picked from commit c8383bb0bc1b94876b295376ebce6e5da77cf624)
IJ-CR-162752
GitOrigin-RevId: 98ae779c270d05997c8245d10abb3d492efdd197
Use averaging functions to report only a couple of values for a batch of samples.
Use a batch size of 50 for typing events and 100 for output events. Output events can occur more often.
So, there will be fewer events reported.
(cherry picked from commit cc6f880e1bc56974656d3e70d7f03da98510568c)
IJ-CR-160384
GitOrigin-RevId: 5dc635d88023c0182af91128077d3882d2003db0
It is just more suitable to have id in all events, not particular ones.
(cherry picked from commit d53c7ce7e6558dd4070b63b763af738dc487d205)
IJ-CR-160384
GitOrigin-RevId: 85b3042a7cecfa30a91eb865bbb508eb769ede13
We need this `readTime` only locally on the backend and put it to the event object only for simplicity.
It is not a good design, but for now there is no suitable alternative. Ideally, we need to have the separate serializable DTO classes hierarchy for RPC.
Or switch to plain longs for measuring the time.
(cherry picked from commit f8e20acdfe0d856c73750711d1a14917fc9b5973)
IJ-CR-160384
GitOrigin-RevId: e12a5a402f4065595b9ed2f25c79bdfb7f5a6734
This implementation is more simple:
1. We track the last time of reading from the TTY.
2. We remember the time from step 1 when we text buffer is changed the first time. Here output accumulation session starts.
3. Once output is collected, we put the time from step 2 to the created `TerminalOutputUpdatedEvent` and reset it. Here output accumulation session ends.
4. Once we update the backend models with this event, we report the backend output latency and forward the event to the frontend.
(cherry picked from commit ed4e4920b46e5bdd7feb27fa7200e4858b629632)
IJ-CR-160384
GitOrigin-RevId: e69dbf55349236fa8a4940228631c0f358c6fd60
The hardest part here is to understand when the received data
is actually displayed. The problem is that it may not be displayed
at all, for example, if the editor is hidden or scrolled away.
Using the hooks added to the editor, we can make an assumption:
if the editor is showing, and there was a repaint request,
then it's very likely to be repainted soon. In that case we wait
for the repaint before reporting the latency.
If there's no repaint request, then we report the latency immediately,
adding a boolean flag to the event to distinguish between the cases.
Because events are received and applied as whole,
there are no separate events for the first and last characters.
Instead, we report both character indices in one event.
So for two backend events we have one frontend event.
(cherry picked from commit df72687dc3ef31bece6eeaf7cd624dc18c462d6e)
IJ-CR-160384
GitOrigin-RevId: ae6f6527f332cd31f20735238a9748249aa27bc5
This process is not single-threaded, but it involves only
one thread transfer: from the receiving coroutine
to the terminal thread, which uses an executor
that is never shut down, so it's pretty much a guarantee
that for every byte array there will be at least an attempt
to write it. Using this fact, we can store a byte array to activity
map and remove activities when the byte arrays are written.
Using a try-finally block there ensures that the activity is eventually
finished.
The activity ID is transferred along with the event,
to ensure that the same ID is used on the frontend and on the backend.
(cherry picked from commit 66587a5cca59053dab1e4bf2bee9bd098fe10637)
IJ-CR-160384
GitOrigin-RevId: c1b9cdb9f30723f0d98fd211c94494e59b2d7eb4
To ensure that the current size is always valid,
make both parse() and ofFloat() coerce the value
into the valid range and then use the wrapper class
for TerminalFontSizeProviderImpl internal state.
(cherry picked from commit 31d0916587d84f83c4375dc6868ffc63cb16c136)
IJ-CR-160631
GitOrigin-RevId: 6c9c86ee434311676719adf6309f42343088b6a4
Disable the editor's actions to avoid conflicts. For this,
add a boolean property to the strategy API.
Implement a new editor size handler for the reworked
terminal. For that, provide the font size service
as a data key in the editor, so the actions
located in execution-impl can access the service
internal to the terminal otherwise.
While we're at it, introduce action text overrides for
Search Everywhere to avoid confusion between editor's
and terminal's actions.
Note that the reset font size actions are available
from both the terminal and the editor. This is,
unfortunately, necessary at this point because
that's how that "Reset to XXpt" link works at the moment.
This can be fixed in the future if necessary.
(cherry picked from commit 7c96b64ed1b7d7330a2c64198fb49a45820c2912)
IJ-CR-160631
GitOrigin-RevId: 8c83193d51d71bbe65bdcd939ddedea8a5599901
Extract an abstract handler interface that we can reuse
for the reworked terminal.
(cherry picked from commit 00a3007fb4104bfb590edf373491b34869aea191)
IJ-CR-160631
GitOrigin-RevId: 3b4567a0ac88ae7ad20d2fbb3d36a8c8655ff79d
Rounding to Int was implemented before Float font sizes
became a thing. Now it seems more reasonable to just use Float
everywhere than have a mess of Float and Int with roundings
and conversions.
Drop those 2D suffixes and port everything to Float.
(cherry picked from commit daeb3ae0625dfe029bf92c6a91ea1a43d631aeeb)
IJ-CR-160631
GitOrigin-RevId: 459995b093f506bb803c21a38802c9f94946306b
Whenever the absolute index is used, Int is risking overflowing.
Replace with Long.
Note that StyleRange is also used by the gen1 terminal,
but there its offsets are relative, not absolute.
So for gen1 code, just cast everything to Int as necessary.
(cherry picked from commit 3afff862356f603c5aa50d5023c51c623320103f)
IJ-CR-157580
GitOrigin-RevId: 4cedfa1ec263a21615852ffbf44ded2db547e8c6
If the cursor is on the first line, and it was partially trimmed
(e.g. a very long line being output), then its column index
is not equal to the column index in the document anymore.
This causes a lot of extra spaces to be added to the end
of the line to display the cursor somewhere far beyond
the end.
Fix by keeping track of the characters trimmed from the first
line and by adjusting the cursor position accordingly.
Make sure this new counter is persisted as a part of the state.
Add a test to check both the fix and state dump/restore.
(cherry picked from commit 051518e8f3ae8a8726c627a9c2de55a08c109b53)
IJ-CR-157580
GitOrigin-RevId: de81226bd0ea8f87af0bbccb1663ab70d28fe2c3
So we are able to substitute different implementations.
(cherry picked from commit 5c475255d09f535355c68da9252b683668d16d61)
IJ-CR-158761
GitOrigin-RevId: a543a6cab00004712744b0592ceb9ea92072f0c6
This allows us to have a separate default that comes
from the terminal-specific font settings.
(cherry picked from commit d33695d218b7c3fd306789d8a3f54a5ae6f34c68)
IJ-CR-158761
GitOrigin-RevId: 6acdab529f4acb3775ebd4c038795daa522cac25
Now everything is done through JBTerminalSystemSettingsProviderBase,
so we can override the behavior for the terminal.
(cherry picked from commit a157494d190082e9a62b6130eb11b4cc3d16086c)
IJ-CR-158761
GitOrigin-RevId: 2724e086e4d7f98264d65a6c09ac31674dfe0ec6
To reduce coupling between the settings and the panel.
It'll be needed to implement an alternative settings state
for the terminal, that will respect the new font settings.
(cherry picked from commit a33f1e8528cda117732b78d66c55b7cf7f29616b)
IJ-CR-158761
GitOrigin-RevId: a4cc84eb461a8e0bf932503455d5a264ee4ce707
So it won't brake the overrides.
(cherry picked from commit 17b4deb9a684996bb2bd2dc01f5121a9731f5d4b)
IJ-CR-160254
GitOrigin-RevId: 82d0c6efdc86c25ea6ee3d9abb79e290dbee8721
To keep the JBTerminalSystemSettingsProviderBase interface,
add getColumnSpacing() to it, but keep the rest as-is,
even though we don't really need getTerminalFont(),
but need getTerminalFontName() instead.
Then, in JBTerminalSystemSettingsProvider override everything
relevant so that the actual values from the settings are used
instead.
(cherry picked from commit cb91fa1f26db16cc977e0aeccdb4cdcd472ebf28)
IJ-CR-156671
GitOrigin-RevId: 33da91fe163c56c4d8403e8c16fface83c0784fd
`Channel` as a hot data source is more tailored to this producer-consumer task. Also, `Channel` is simpler than `MutableSharedFlow`.
The problem of buffering `replay` elements could also be fixed with `MutableSharedFlow` and `launch(start = CoroutineStart.UNDISPATCHED)`, but it feels more like a workaround and makes reasoning about code correctness more difficult.
(cherry picked from commit 023a772e351bbc11096d99bd4c2a63a4d0de6b15)
IJ-CR-155762
GitOrigin-RevId: 95e9459e3f82d2b267aa8dd3e246fc565e7894f8
Executing of `exit` command is purely intentional action, we should not ask an additional confirmation in this case.
(cherry picked from commit 8de4bab3d3811feb6d4391782d97c5d62bd6949d)
IJ-CR-157168
GitOrigin-RevId: eab7d429b5adc4e6006a6683424f4499ce8d277b
This value should be stored somewhere, so there are different places:
1. TerminalBlocksModel - looks too specific, our shell integration features can be not about blocks specifically.
2. TerminalSessionModel - the common place for different states and their values. Let's use this place.
(cherry picked from commit a9cfe0166a68e96a4e2f1860dcda7a1078befe6d)
IJ-CR-157017
GitOrigin-RevId: 50e17f1513df103ba43a8bb3a5d35653a13ab9ba
Clarify the choice of the `SendChannel` to send the input events.
(cherry picked from commit 33c03d236fa6317a844da28a4cf264f50461ca00)
IJ-CR-156212
GitOrigin-RevId: 6bc9d427b7805ed9ffac88074ad434f15417fdbb
Use `SendChannel` for this purpose.
Just calling `sendInputEvent` method in the right order does not guarantee the same order on backend.
To guarantee it, we have to wait until `sendInputEvent` method completes (the event is handled on backend) and only then send the new one.
But it is not acceptable in case of typing in RD: the latency would be very noticeable.
We should not wait for handling of the previous event before sending the next one, we should send it immediately.
And hopefully, `SendChannel` acts exactly like that, and also it provides the order guarantees.
(cherry picked from commit f3180a974c6bf8af6d12bd0ffe162d99ed95a31c)
IJ-CR-156212
GitOrigin-RevId: 47aaf8f20d202ec4ad69d8f9c16ccff4e18997ce
We will need to use it in the RPC, so it should be here together with other models we pass through RPC.
GitOrigin-RevId: e973d8375f30765c856b7583f67006091170ac46
`TerminalSession` now has its own lifecycle: it is considered as closed once we receive `TerminalSessionTerminatedEvent`.
`TerminalWidget` is not directly bound to the lifecycle of the session.
Their lifecycles are only connected through the logic in `TerminalToolWindowManager`.
There are several cases considered in this change:
1. Explicitly close the terminal tab: we send `TerminalCloseEvent` to close the session on the backend.
2. User executed `exit` command or pressed Ctrl+D: we terminate session, send `TerminalSessionTerminatedEvent` to frontend and close the terminal tab there.
3. Frontend project is closed, leaving terminal tabs opened: we do not close terminal sessions on backend to make it possible to reconnect. But if the backend is terminated, the sessions will be closed with it.
GitOrigin-RevId: 1ecaba10d2a7cff3b391bee3484cd53808473866