mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Generate temp files as not dirty (#3698)
* Generate temp files as not dirty * Remove whitespace
This commit is contained in:
@@ -346,6 +346,11 @@ let registryProperties = {
|
|||||||
'description': localize('showConnectionInfoInTitle', "Controls whether to show the connection info for a tab in the title."),
|
'description': localize('showConnectionInfoInTitle', "Controls whether to show the connection info for a tab in the title."),
|
||||||
'default': true
|
'default': true
|
||||||
},
|
},
|
||||||
|
'sql.promptToSaveGeneratedFiles': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'default': false,
|
||||||
|
'description': localize('sql.promptToSaveGeneratedFiles', 'Prompt to save generated SQL files')
|
||||||
|
},
|
||||||
'mssql.intelliSense.enableIntelliSense': {
|
'mssql.intelliSense.enableIntelliSense': {
|
||||||
'type': 'boolean',
|
'type': 'boolean',
|
||||||
'default': true,
|
'default': true,
|
||||||
@@ -413,6 +418,3 @@ configurationRegistry.registerConfiguration({
|
|||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': registryProperties
|
'properties': registryProperties
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export interface IQueryEditorService {
|
|||||||
_serviceBrand: any;
|
_serviceBrand: any;
|
||||||
|
|
||||||
// Creates new untitled document for SQL queries and opens it in a new editor tab
|
// Creates new untitled document for SQL queries and opens it in a new editor tab
|
||||||
newSqlEditor(sqlContent?: string, connectionProviderName?: string): Promise<IConnectableInput>;
|
newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean): Promise<IConnectableInput>;
|
||||||
|
|
||||||
// Creates a new query plan document
|
// Creates a new query plan document
|
||||||
newQueryPlanEditor(xmlShowPlan: string): Promise<any>;
|
newQueryPlanEditor(xmlShowPlan: string): Promise<any>;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
|||||||
import { EditDataResultsInput } from 'sql/parts/editData/common/editDataResultsInput';
|
import { EditDataResultsInput } from 'sql/parts/editData/common/editDataResultsInput';
|
||||||
import { IEditorInput, IEditor } from 'vs/workbench/common/editor';
|
import { IEditorInput, IEditor } from 'vs/workbench/common/editor';
|
||||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||||
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
@@ -61,7 +62,8 @@ export class QueryEditorService implements IQueryEditorService {
|
|||||||
@IEditorService private _editorService: IEditorService,
|
@IEditorService private _editorService: IEditorService,
|
||||||
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
|
||||||
@INotificationService private _notificationService: INotificationService,
|
@INotificationService private _notificationService: INotificationService,
|
||||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService
|
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||||
|
@IConfigurationService private _configurationService: IConfigurationService
|
||||||
) {
|
) {
|
||||||
QueryEditorService.editorService = _editorService;
|
QueryEditorService.editorService = _editorService;
|
||||||
QueryEditorService.instantiationService = _instantiationService;
|
QueryEditorService.instantiationService = _instantiationService;
|
||||||
@@ -74,7 +76,7 @@ export class QueryEditorService implements IQueryEditorService {
|
|||||||
/**
|
/**
|
||||||
* Creates new untitled document for SQL query and opens in new editor tab
|
* Creates new untitled document for SQL query and opens in new editor tab
|
||||||
*/
|
*/
|
||||||
public newSqlEditor(sqlContent?: string, connectionProviderName?: string): Promise<IConnectableInput> {
|
public newSqlEditor(sqlContent?: string, connectionProviderName?: string, isDirty?: boolean): Promise<IConnectableInput> {
|
||||||
return new Promise<IConnectableInput>((resolve, reject) => {
|
return new Promise<IConnectableInput>((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
// Create file path and file URI
|
// Create file path and file URI
|
||||||
@@ -86,6 +88,9 @@ export class QueryEditorService implements IQueryEditorService {
|
|||||||
fileInput.resolve().then(m => {
|
fileInput.resolve().then(m => {
|
||||||
if (sqlContent) {
|
if (sqlContent) {
|
||||||
m.textEditorModel.setValue(sqlContent);
|
m.textEditorModel.setValue(sqlContent);
|
||||||
|
if (isDirty === false || (isDirty === undefined && !this._configurationService.getValue<boolean>('sql.promptToSaveGeneratedFiles'))) {
|
||||||
|
m.setDirty(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { ResourceMap } from 'vs/base/common/map';
|
|||||||
|
|
||||||
// {{SQL CARBON EDIT}}
|
// {{SQL CARBON EDIT}}
|
||||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||||
|
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||||
import * as CustomInputConverter from 'sql/parts/common/customInputConverter';
|
import * as CustomInputConverter from 'sql/parts/common/customInputConverter';
|
||||||
|
|
||||||
const EditorOpenPositioning = {
|
const EditorOpenPositioning = {
|
||||||
@@ -631,6 +632,14 @@ export class EditorGroup extends Disposable {
|
|||||||
editors.forEach(e => {
|
editors.forEach(e => {
|
||||||
let factory = registry.getEditorInputFactory(e.getTypeId());
|
let factory = registry.getEditorInputFactory(e.getTypeId());
|
||||||
if (factory) {
|
if (factory) {
|
||||||
|
|
||||||
|
// {{SQL CARBON EDIT}}
|
||||||
|
// don't serialize unmodified unitited files
|
||||||
|
if (e instanceof UntitledEditorInput && !e.isDirty()
|
||||||
|
&& !this.configurationService.getValue<boolean>('sql.promptToSaveGeneratedFiles')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let value = factory.serialize(e);
|
let value = factory.serialize(e);
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
serializedEditors.push({ id: e.getTypeId(), value });
|
serializedEditors.push({ id: e.getTypeId(), value });
|
||||||
|
|||||||
@@ -115,7 +115,9 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
|
|||||||
return this.dirty;
|
return this.dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setDirty(dirty: boolean): void {
|
// {{SQL CARBON EDIT}}
|
||||||
|
// make property public
|
||||||
|
public setDirty(dirty: boolean): void {
|
||||||
if (this.dirty === dirty) {
|
if (this.dirty === dirty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user