Skip to content

Commit 26aa72b

Browse files
authored
Merge pull request microsoft#153326 from microsoft/tyriar/152381
Change view size to change term view by 4 cells
2 parents 46106c7 + d48f343 commit 26aa72b

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/vs/workbench/contrib/terminal/browser/terminalGroup.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ import { IShellLaunchConfig, ITerminalTabLayoutInfoById } from 'vs/platform/term
1515
import { TerminalStatus } from 'vs/workbench/contrib/terminal/browser/terminalStatusList';
1616
import { getPartByLocation } from 'vs/workbench/browser/parts/views/viewsService';
1717

18-
const SPLIT_PANE_MIN_SIZE = 120;
18+
const enum Constants {
19+
/**
20+
* The minimum size in pixels of a split pane.
21+
*/
22+
SplitPaneMinSize = 120,
23+
/**
24+
* The number of cells the terminal gets added or removed when asked to increase or decrease
25+
* the view size.
26+
*/
27+
ResizePartCellCount = 4
28+
}
1929

2030
class SplitPaneContainer extends Disposable {
2131
private _height: number;
@@ -91,10 +101,10 @@ class SplitPaneContainer extends Disposable {
91101
}
92102

93103
// Ensure the size is not reduced beyond the minimum, otherwise weird things can happen
94-
if (sizes[index] + amount < SPLIT_PANE_MIN_SIZE) {
95-
amount = SPLIT_PANE_MIN_SIZE - sizes[index];
96-
} else if (sizes[indexToChange] - amount < SPLIT_PANE_MIN_SIZE) {
97-
amount = sizes[indexToChange] - SPLIT_PANE_MIN_SIZE;
104+
if (sizes[index] + amount < Constants.SplitPaneMinSize) {
105+
amount = Constants.SplitPaneMinSize - sizes[index];
106+
} else if (sizes[indexToChange] - amount < Constants.SplitPaneMinSize) {
107+
amount = sizes[indexToChange] - Constants.SplitPaneMinSize;
98108
}
99109

100110
// Apply the size change
@@ -207,7 +217,7 @@ class SplitPaneContainer extends Disposable {
207217
}
208218

209219
class SplitPane implements IView {
210-
minimumSize: number = SPLIT_PANE_MIN_SIZE;
220+
minimumSize: number = Constants.SplitPaneMinSize;
211221
maximumSize: number = Number.MAX_VALUE;
212222

213223
orientation: Orientation | undefined;
@@ -560,9 +570,9 @@ export class TerminalGroup extends Disposable implements ITerminalGroup {
560570
const isHorizontal = (direction === Direction.Left || direction === Direction.Right);
561571
const font = this._terminalService.configHelper.getFont();
562572
// TODO: Support letter spacing and line height
563-
const amount = isHorizontal ? font.charWidth : font.charHeight;
564-
if (amount) {
565-
this._splitPaneContainer.resizePane(this._activeInstanceIndex, direction, amount, getPartByLocation(this._terminalLocation));
573+
const charSize = (isHorizontal ? font.charWidth : font.charHeight);
574+
if (charSize) {
575+
this._splitPaneContainer.resizePane(this._activeInstanceIndex, direction, charSize * Constants.ResizePartCellCount, getPartByLocation(this._terminalLocation));
566576
}
567577
}
568578

0 commit comments

Comments
 (0)