Fix Notebooks Word Wrapping Logic (#11415)

* make word wrap logic easier

* Stop passing in IConfigurationService
This commit is contained in:
Chris LaFreniere
2020-07-20 13:50:26 -07:00
committed by GitHub
parent 047c51921b
commit 3792a6328f
3 changed files with 5 additions and 15 deletions

View File

@@ -20,7 +20,6 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput'; import { UntitledTextEditorInput } from 'vs/workbench/services/untitled/common/untitledTextEditorInput';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
@@ -35,7 +34,6 @@ export class QueryTextEditor extends BaseTextEditor {
private _maxHeight: number = 4000; private _maxHeight: number = 4000;
private _selected: boolean; private _selected: boolean;
private _hideLineNumbers: boolean; private _hideLineNumbers: boolean;
private _editorWorkspaceConfig;
private _scrollbarHeight: number; private _scrollbarHeight: number;
private _lineHeight: number; private _lineHeight: number;
@@ -46,9 +44,7 @@ export class QueryTextEditor extends BaseTextEditor {
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService, @ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
@IEditorGroupsService editorGroupService: IEditorGroupsService, @IEditorGroupsService editorGroupService: IEditorGroupsService,
@IEditorService protected editorService: IEditorService, @IEditorService protected editorService: IEditorService
@IConfigurationService private workspaceConfigurationService: IConfigurationService
) { ) {
super( super(
QueryTextEditor.ID, telemetryService, instantiationService, storageService, QueryTextEditor.ID, telemetryService, instantiationService, storageService,
@@ -150,12 +146,10 @@ export class QueryTextEditor extends BaseTextEditor {
// that the viewportColumn will always be greater than any character's column in an editor. // that the viewportColumn will always be greater than any character's column in an editor.
let numberWrappedLines = 0; let numberWrappedLines = 0;
let shouldAddHorizontalScrollbarHeight = false; let shouldAddHorizontalScrollbarHeight = false;
if (!this._editorWorkspaceConfig || configChanged) { if (!this._lineHeight || configChanged) {
this._editorWorkspaceConfig = this.workspaceConfigurationService.getValue('editor');
this._lineHeight = editorWidget.getOption(EditorOption.lineHeight) || 18; this._lineHeight = editorWidget.getOption(EditorOption.lineHeight) || 18;
} }
let wordWrapEnabled: boolean = this._editorWorkspaceConfig && this._editorWorkspaceConfig['wordWrap'] && this._editorWorkspaceConfig['wordWrap'] === 'on' ? true : false; if (layoutInfo.isViewportWrapping) {
if (wordWrapEnabled) {
for (let line = 1; line <= lineCount; line++) { for (let line = 1; line <= lineCount; line++) {
// 2 columns is equivalent to the viewport column width and the edge of the editor // 2 columns is equivalent to the viewport column width and the edge of the editor
if (editorWidgetModel.getLineMaxColumn(line) >= layoutInfo.viewportColumn + 2) { if (editorWidgetModel.getLineMaxColumn(line) >= layoutInfo.viewportColumn + 2) {

View File

@@ -32,7 +32,6 @@ import { IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editor
import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService'; import { ITextResourceConfigurationService } from 'vs/editor/common/services/textResourceConfigurationService';
import { FindReplaceStateChangedEvent, INewFindReplaceState } from 'vs/editor/contrib/find/findState'; import { FindReplaceStateChangedEvent, INewFindReplaceState } from 'vs/editor/contrib/find/findState';
import { getRandomString } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils'; import { getRandomString } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService'; import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
import { DidInstallExtensionEvent, DidUninstallExtensionEvent, IExtensionManagementService, InstallExtensionEvent } from 'vs/platform/extensionManagement/common/extensionManagement'; import { DidInstallExtensionEvent, DidUninstallExtensionEvent, IExtensionManagementService, InstallExtensionEvent } from 'vs/platform/extensionManagement/common/extensionManagement';
@@ -717,8 +716,7 @@ function setupServices(arg: { workbenchThemeService?: WorkbenchThemeService, ins
instantiationService.get(ITextResourceConfigurationService), instantiationService.get(ITextResourceConfigurationService),
instantiationService.get(IThemeService), instantiationService.get(IThemeService),
instantiationService.get(IEditorGroupsService), instantiationService.get(IEditorGroupsService),
instantiationService.get(IEditorService), instantiationService.get(IEditorService)
instantiationService.get(IConfigurationService)
); );
const notebookEditorStub = new NotebookEditorStub({ cellGuid: cellTextEditorGuid, editor: queryTextEditor, model: new NotebookModelStub(), notebookParams: <INotebookParams>{ notebookUri: untitledNotebookInput.notebookUri } }); const notebookEditorStub = new NotebookEditorStub({ cellGuid: cellTextEditorGuid, editor: queryTextEditor, model: new NotebookModelStub(), notebookParams: <INotebookParams>{ notebookUri: untitledNotebookInput.notebookUri } });
notebookService.addNotebookEditor(notebookEditorStub); notebookService.addNotebookEditor(notebookEditorStub);

View File

@@ -8,7 +8,6 @@ import * as stubs from 'sql/workbench/contrib/notebook/test/stubs';
import { INotebookModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces'; import { INotebookModel } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { INotebookParams } from 'sql/workbench/services/notebook/browser/notebookService'; import { INotebookParams } from 'sql/workbench/services/notebook/browser/notebookService';
import * as dom from 'vs/base/browser/dom'; import * as dom from 'vs/base/browser/dom';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService'; import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
@@ -55,8 +54,7 @@ class CellEditorProviderStub extends stubs.CellEditorProviderStub {
new TestTextResourceConfigurationService(), new TestTextResourceConfigurationService(),
new TestThemeService(), new TestThemeService(),
new TestEditorGroupsService(), new TestEditorGroupsService(),
new TestEditorService(), new TestEditorService()
new TestConfigurationService()
); );
} }
if (this._editor) { if (this._editor) {