Skip to content

Commit

Permalink
Fix #34744. No width check when users never resize the find widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Nov 27, 2017
1 parent 91b4159 commit 2663114
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/vs/editor/contrib/find/findWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
private _viewZoneId: number;

private _resizeSash: Sash;
private _resized: boolean;

constructor(
codeEditor: ICodeEditor,
Expand Down Expand Up @@ -505,13 +506,16 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
let collapsedFindWidget = false;
let reducedFindWidget = false;
let narrowFindWidget = false;
let widgetWidth = dom.getTotalWidth(this._domNode);

if (widgetWidth > FIND_WIDGET_INITIAL_WIDTH) {
// as the widget is resized by users, we may need to change the max width of the widget as the editor width changes.
this._domNode.style.maxWidth = `${editorWidth - 28 - minimapWidth - 15}px`;
this._replaceInputBox.inputElement.style.width = `${dom.getTotalWidth(this._findInput.inputBox.inputElement)}px`;
return;
if (this._resized) {
let widgetWidth = dom.getTotalWidth(this._domNode);

if (widgetWidth > FIND_WIDGET_INITIAL_WIDTH) {
// as the widget is resized by users, we may need to change the max width of the widget as the editor width changes.
this._domNode.style.maxWidth = `${editorWidth - 28 - minimapWidth - 15}px`;
this._replaceInputBox.inputElement.style.width = `${dom.getTotalWidth(this._findInput.inputBox.inputElement)}px`;
return;
}
}

if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth >= editorWidth) {
Expand All @@ -532,9 +536,11 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
this._domNode.style.maxWidth = `${editorWidth - 28 - minimapWidth - 15}px`;
}

let findInputWidth = dom.getTotalWidth(this._findInput.inputBox.inputElement);
if (findInputWidth > 0) {
this._replaceInputBox.inputElement.style.width = `${findInputWidth}px`;
if (this._resized) {
let findInputWidth = dom.getTotalWidth(this._findInput.inputBox.inputElement);
if (findInputWidth > 0) {
this._replaceInputBox.inputElement.style.width = `${findInputWidth}px`;
}
}
}

Expand Down Expand Up @@ -865,13 +871,15 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas

private _buildSash() {
this._resizeSash = new Sash(this._domNode, this, { orientation: Orientation.VERTICAL });
this._resized = false;
let originalWidth = FIND_WIDGET_INITIAL_WIDTH;

this._register(this._resizeSash.onDidStart((e: ISashEvent) => {
originalWidth = dom.getTotalWidth(this._domNode);
}));

this._register(this._resizeSash.onDidChange((evt: ISashEvent) => {
this._resized = true;
let width = originalWidth + evt.startX - evt.currentX;

if (width < FIND_WIDGET_INITIAL_WIDTH) {
Expand Down

0 comments on commit 2663114

Please sign in to comment.