mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 6fded8a497cd0142de3a1c607649a5423a091a25
This commit is contained in:
@@ -890,15 +890,18 @@ export class TokensStore2 {
|
||||
}
|
||||
|
||||
public setPartial(_range: Range, pieces: MultilineTokens2[]): Range {
|
||||
if (pieces.length === 0) {
|
||||
return _range;
|
||||
// console.log(`setPartial ${_range} ${pieces.map(p => p.toString()).join(', ')}`);
|
||||
|
||||
let range = _range;
|
||||
if (pieces.length > 0) {
|
||||
const _firstRange = pieces[0].getRange();
|
||||
const _lastRange = pieces[pieces.length - 1].getRange();
|
||||
if (!_firstRange || !_lastRange) {
|
||||
return _range;
|
||||
}
|
||||
range = _range.plusRange(_firstRange).plusRange(_lastRange);
|
||||
}
|
||||
const _firstRange = pieces[0].getRange();
|
||||
const _lastRange = pieces[pieces.length - 1].getRange();
|
||||
if (!_firstRange || !_lastRange) {
|
||||
return _range;
|
||||
}
|
||||
const range = _range.plusRange(_firstRange).plusRange(_lastRange);
|
||||
|
||||
let insertPosition: { index: number; } | null = null;
|
||||
for (let i = 0, len = this._pieces.length; i < len; i++) {
|
||||
const piece = this._pieces[i];
|
||||
@@ -938,6 +941,15 @@ export class TokensStore2 {
|
||||
|
||||
// after removal, this piece contains the range
|
||||
const [a, b] = piece.split(range);
|
||||
if (a.isEmpty()) {
|
||||
// this piece is actually after the range
|
||||
insertPosition = insertPosition || { index: i };
|
||||
continue;
|
||||
}
|
||||
if (b.isEmpty()) {
|
||||
// this piece is actually before the range
|
||||
continue;
|
||||
}
|
||||
this._pieces.splice(i, 1, a, b);
|
||||
i++;
|
||||
len++;
|
||||
@@ -947,10 +959,12 @@ export class TokensStore2 {
|
||||
|
||||
insertPosition = insertPosition || { index: this._pieces.length };
|
||||
|
||||
this._pieces = arrays.arrayInsert(this._pieces, insertPosition.index, pieces);
|
||||
if (pieces.length > 0) {
|
||||
this._pieces = arrays.arrayInsert(this._pieces, insertPosition.index, pieces);
|
||||
}
|
||||
|
||||
// console.log(`I HAVE ${this._pieces.length} pieces`);
|
||||
// console.log(`${this._pieces.map(p => p.toString()).join(', ')}`);
|
||||
// console.log(`${this._pieces.map(p => p.toString()).join('\n')}`);
|
||||
|
||||
return range;
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ export class ModelServiceImpl extends Disposable implements IModelService {
|
||||
const model = modelData.model;
|
||||
let maintainUndoRedoStack = false;
|
||||
let heapSize = 0;
|
||||
if (MAINTAIN_UNDO_REDO_STACK && (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote)) {
|
||||
if (MAINTAIN_UNDO_REDO_STACK && (resource.scheme === Schemas.file || resource.scheme === Schemas.vscodeRemote || resource.scheme === Schemas.userData)) {
|
||||
const elements = this._undoRedoService.getElements(resource);
|
||||
if ((elements.past.length > 0 || elements.future.length > 0) && isEditStackPastFutureElements(elements)) {
|
||||
maintainUndoRedoStack = true;
|
||||
@@ -577,9 +577,17 @@ export interface ILineSequence {
|
||||
getLineContent(lineNumber: number): string;
|
||||
}
|
||||
|
||||
class SemanticColoringFeature extends Disposable {
|
||||
export const SEMANTIC_HIGHLIGHTING_SETTING_ID = 'editor.semanticHighlighting';
|
||||
|
||||
private static readonly SETTING_ID = 'editor.semanticHighlighting';
|
||||
export function isSemanticColoringEnabled(model: ITextModel, themeService: IThemeService, configurationService: IConfigurationService): boolean {
|
||||
if (!themeService.getColorTheme().semanticHighlighting) {
|
||||
return false;
|
||||
}
|
||||
const options = configurationService.getValue<IEditorSemanticHighlightingOptions>(SEMANTIC_HIGHLIGHTING_SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri });
|
||||
return Boolean(options && options.enabled);
|
||||
}
|
||||
|
||||
class SemanticColoringFeature extends Disposable {
|
||||
|
||||
private readonly _watchers: Record<string, ModelSemanticColoring>;
|
||||
private readonly _semanticStyling: SemanticStyling;
|
||||
@@ -589,13 +597,6 @@ class SemanticColoringFeature extends Disposable {
|
||||
this._watchers = Object.create(null);
|
||||
this._semanticStyling = semanticStyling;
|
||||
|
||||
const isSemanticColoringEnabled = (model: ITextModel) => {
|
||||
if (!themeService.getColorTheme().semanticHighlighting) {
|
||||
return false;
|
||||
}
|
||||
const options = configurationService.getValue<IEditorSemanticHighlightingOptions>(SemanticColoringFeature.SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri });
|
||||
return options && options.enabled;
|
||||
};
|
||||
const register = (model: ITextModel) => {
|
||||
this._watchers[model.uri.toString()] = new ModelSemanticColoring(model, themeService, this._semanticStyling);
|
||||
};
|
||||
@@ -606,7 +607,7 @@ class SemanticColoringFeature extends Disposable {
|
||||
const handleSettingOrThemeChange = () => {
|
||||
for (let model of modelService.getModels()) {
|
||||
const curr = this._watchers[model.uri.toString()];
|
||||
if (isSemanticColoringEnabled(model)) {
|
||||
if (isSemanticColoringEnabled(model, themeService, configurationService)) {
|
||||
if (!curr) {
|
||||
register(model);
|
||||
}
|
||||
@@ -618,7 +619,7 @@ class SemanticColoringFeature extends Disposable {
|
||||
}
|
||||
};
|
||||
this._register(modelService.onModelAdded((model) => {
|
||||
if (isSemanticColoringEnabled(model)) {
|
||||
if (isSemanticColoringEnabled(model, themeService, configurationService)) {
|
||||
register(model);
|
||||
}
|
||||
}));
|
||||
@@ -629,7 +630,7 @@ class SemanticColoringFeature extends Disposable {
|
||||
}
|
||||
}));
|
||||
this._register(configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration(SemanticColoringFeature.SETTING_ID)) {
|
||||
if (e.affectsConfiguration(SEMANTIC_HIGHLIGHTING_SETTING_ID)) {
|
||||
handleSettingOrThemeChange();
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -402,8 +402,26 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
|
||||
this._updateConfigurationViewLineCount.schedule();
|
||||
}
|
||||
|
||||
public getVisibleRangesPlusViewportAboveBelow(): Range[] {
|
||||
const layoutInfo = this.configuration.options.get(EditorOption.layoutInfo);
|
||||
const lineHeight = this.configuration.options.get(EditorOption.lineHeight);
|
||||
const linesAround = Math.max(20, Math.round(layoutInfo.height / lineHeight));
|
||||
const partialData = this.viewLayout.getLinesViewportData();
|
||||
const startViewLineNumber = Math.max(1, partialData.completelyVisibleStartLineNumber - linesAround);
|
||||
const endViewLineNumber = Math.min(this.getLineCount(), partialData.completelyVisibleEndLineNumber + linesAround);
|
||||
|
||||
return this._toModelVisibleRanges(new Range(
|
||||
startViewLineNumber, this.getLineMinColumn(startViewLineNumber),
|
||||
endViewLineNumber, this.getLineMaxColumn(endViewLineNumber)
|
||||
));
|
||||
}
|
||||
|
||||
public getVisibleRanges(): Range[] {
|
||||
const visibleViewRange = this.getCompletelyVisibleViewRange();
|
||||
return this._toModelVisibleRanges(visibleViewRange);
|
||||
}
|
||||
|
||||
private _toModelVisibleRanges(visibleViewRange: Range): Range[] {
|
||||
const visibleRange = this.coordinatesConverter.convertViewRangeToModelRange(visibleViewRange);
|
||||
const hiddenAreas = this.lines.getHiddenAreas();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user