Commit 58086f82 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'fix-ide-empty-editor' into 'master'

Fixed empty editors in the IDE

Closes #46153

See merge request gitlab-org/gitlab-ce!18842
parents f29e6937 96785e77
...@@ -14,12 +14,12 @@ export default class Model { ...@@ -14,12 +14,12 @@ export default class Model {
(this.originalModel = this.monaco.editor.createModel( (this.originalModel = this.monaco.editor.createModel(
head ? head.content : this.file.raw, head ? head.content : this.file.raw,
undefined, undefined,
new this.monaco.Uri(null, null, `original/${this.file.key}`), new this.monaco.Uri(null, null, `original/${this.path}`),
)), )),
(this.model = this.monaco.editor.createModel( (this.model = this.monaco.editor.createModel(
this.content, this.content,
undefined, undefined,
new this.monaco.Uri(null, null, this.file.key), new this.monaco.Uri(null, null, this.path),
)), )),
); );
if (this.file.mrChange) { if (this.file.mrChange) {
...@@ -27,7 +27,7 @@ export default class Model { ...@@ -27,7 +27,7 @@ export default class Model {
(this.baseModel = this.monaco.editor.createModel( (this.baseModel = this.monaco.editor.createModel(
this.file.baseRaw, this.file.baseRaw,
undefined, undefined,
new this.monaco.Uri(null, null, `target/${this.file.path}`), new this.monaco.Uri(null, null, `target/${this.path}`),
)), )),
); );
} }
......
...@@ -196,6 +196,8 @@ export const unstageChange = ({ commit }, path) => { ...@@ -196,6 +196,8 @@ export const unstageChange = ({ commit }, path) => {
}; };
export const openPendingTab = ({ commit, getters, dispatch, state }, { file, keyPrefix }) => { export const openPendingTab = ({ commit, getters, dispatch, state }, { file, keyPrefix }) => {
if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false;
state.openFiles.forEach(f => eventHub.$emit(`editor.update.model.dispose.${f.key}`)); state.openFiles.forEach(f => eventHub.$emit(`editor.update.model.dispose.${f.key}`));
commit(types.ADD_PENDING_TAB, { file, keyPrefix }); commit(types.ADD_PENDING_TAB, { file, keyPrefix });
......
...@@ -28,6 +28,10 @@ describe('Multi-file editor library model', () => { ...@@ -28,6 +28,10 @@ describe('Multi-file editor library model', () => {
expect(model.originalModel).not.toBeNull(); expect(model.originalModel).not.toBeNull();
expect(model.model).not.toBeNull(); expect(model.model).not.toBeNull();
expect(model.baseModel).not.toBeNull(); expect(model.baseModel).not.toBeNull();
expect(model.originalModel.uri.path).toBe('original/path--path');
expect(model.model.uri.path).toBe('path--path');
expect(model.baseModel.uri.path).toBe('target/path--path');
}); });
it('creates model with head file to compare against', () => { it('creates model with head file to compare against', () => {
......
...@@ -569,6 +569,22 @@ describe('IDE store file actions', () => { ...@@ -569,6 +569,22 @@ describe('IDE store file actions', () => {
.catch(done.fail); .catch(done.fail);
}); });
it('returns false when already opened', done => {
store.state.openFiles.push({
...f,
active: true,
key: `pending-${f.key}`,
});
store
.dispatch('openPendingTab', { file: f, keyPrefix: 'pending' })
.then(added => {
expect(added).toBe(false);
})
.then(done)
.catch(done.fail);
});
it('pushes router URL when added', done => { it('pushes router URL when added', done => {
store.state.currentBranchId = 'master'; store.state.currentBranchId = 'master';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment