Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1b954408
Commit
1b954408
authored
May 11, 2021
by
Denys Mishunov
Committed by
Jacques Erasmus
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset editor's layout after StartupCSS
parent
3a8ed5be
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
0 deletions
+50
-0
app/assets/javascripts/editor/extensions/editor_lite_extension_base.js
...vascripts/editor/extensions/editor_lite_extension_base.js
+8
-0
changelogs/unreleased/dmishunov-editor-fix-rendering.yml
changelogs/unreleased/dmishunov-editor-fix-rendering.yml
+5
-0
spec/frontend/editor/editor_lite_extension_base_spec.js
spec/frontend/editor/editor_lite_extension_base_spec.js
+32
-0
spec/frontend/pipeline_editor/components/editor/text_editor_spec.js
...end/pipeline_editor/components/editor/text_editor_spec.js
+5
-0
No files found.
app/assets/javascripts/editor/extensions/editor_lite_extension_base.js
View file @
1b954408
import
{
Range
}
from
'
monaco-editor
'
;
import
{
Range
}
from
'
monaco-editor
'
;
import
{
waitForCSSLoaded
}
from
'
~/helpers/startup_css_helper
'
;
import
{
ERROR_INSTANCE_REQUIRED_FOR_EXTENSION
,
EDITOR_TYPE_CODE
}
from
'
../constants
'
;
import
{
ERROR_INSTANCE_REQUIRED_FOR_EXTENSION
,
EDITOR_TYPE_CODE
}
from
'
../constants
'
;
const
hashRegexp
=
new
RegExp
(
'
#?L
'
,
'
g
'
);
const
hashRegexp
=
new
RegExp
(
'
#?L
'
,
'
g
'
);
...
@@ -25,11 +26,18 @@ export class EditorLiteExtension {
...
@@ -25,11 +26,18 @@ export class EditorLiteExtension {
if
(
instance
.
getEditorType
&&
instance
.
getEditorType
()
===
EDITOR_TYPE_CODE
)
{
if
(
instance
.
getEditorType
&&
instance
.
getEditorType
()
===
EDITOR_TYPE_CODE
)
{
EditorLiteExtension
.
setupLineLinking
(
instance
);
EditorLiteExtension
.
setupLineLinking
(
instance
);
}
}
EditorLiteExtension
.
deferRerender
(
instance
);
}
else
if
(
Object
.
entries
(
options
).
length
)
{
}
else
if
(
Object
.
entries
(
options
).
length
)
{
throw
new
Error
(
ERROR_INSTANCE_REQUIRED_FOR_EXTENSION
);
throw
new
Error
(
ERROR_INSTANCE_REQUIRED_FOR_EXTENSION
);
}
}
}
}
static
deferRerender
(
instance
)
{
waitForCSSLoaded
(()
=>
{
instance
.
layout
();
});
}
static
highlightLines
(
instance
)
{
static
highlightLines
(
instance
)
{
const
{
hash
}
=
window
.
location
;
const
{
hash
}
=
window
.
location
;
if
(
!
hash
)
{
if
(
!
hash
)
{
...
...
changelogs/unreleased/dmishunov-editor-fix-rendering.yml
0 → 100644
View file @
1b954408
---
title
:
Reset Source Editor's layout after Startup CSS
merge_request
:
61426
author
:
type
:
fixed
spec/frontend/editor/editor_lite_extension_base_spec.js
View file @
1b954408
...
@@ -7,6 +7,21 @@ import {
...
@@ -7,6 +7,21 @@ import {
}
from
'
~/editor/constants
'
;
}
from
'
~/editor/constants
'
;
import
{
EditorLiteExtension
}
from
'
~/editor/extensions/editor_lite_extension_base
'
;
import
{
EditorLiteExtension
}
from
'
~/editor/extensions/editor_lite_extension_base
'
;
jest
.
mock
(
'
~/helpers/startup_css_helper
'
,
()
=>
{
return
{
waitForCSSLoaded
:
jest
.
fn
().
mockImplementation
((
cb
)
=>
{
// We have to artificially put the callback's execution
// to the end of the current call stack to be able to
// test that the callback is called after waitForCSSLoaded.
// setTimeout with 0 delay does exactly that.
// Otherwise we might end up with false positive results
setTimeout
(()
=>
{
cb
.
apply
();
},
0
);
}),
};
});
describe
(
'
The basis for an Editor Lite extension
'
,
()
=>
{
describe
(
'
The basis for an Editor Lite extension
'
,
()
=>
{
const
defaultLine
=
3
;
const
defaultLine
=
3
;
let
ext
;
let
ext
;
...
@@ -44,6 +59,19 @@ describe('The basis for an Editor Lite extension', () => {
...
@@ -44,6 +59,19 @@ describe('The basis for an Editor Lite extension', () => {
});
});
describe
(
'
constructor
'
,
()
=>
{
describe
(
'
constructor
'
,
()
=>
{
it
(
'
resets the layout in waitForCSSLoaded callback
'
,
async
()
=>
{
const
instance
=
{
layout
:
jest
.
fn
(),
};
ext
=
new
EditorLiteExtension
({
instance
});
expect
(
instance
.
layout
).
not
.
toHaveBeenCalled
();
// We're waiting for the waitForCSSLoaded mock to kick in
await
jest
.
runOnlyPendingTimers
();
expect
(
instance
.
layout
).
toHaveBeenCalled
();
});
it
.
each
`
it
.
each
`
description | instance | options
description | instance | options
${
'
accepts configuration options and instance
'
}
|
${{}}
|
$
{
defaultOptions
}
${
'
accepts configuration options and instance
'
}
|
${{}}
|
$
{
defaultOptions
}
...
@@ -51,6 +79,7 @@ describe('The basis for an Editor Lite extension', () => {
...
@@ -51,6 +79,7 @@ describe('The basis for an Editor Lite extension', () => {
${
'
does not fail if both instance and the options are omitted
'
}
|
${
undefined
}
|
${
undefined
}
${
'
does not fail if both instance and the options are omitted
'
}
|
${
undefined
}
|
${
undefined
}
${
'
throws if only options are passed
'
}
|
${
undefined
}
|
${
defaultOptions
}
${
'
throws if only options are passed
'
}
|
${
undefined
}
|
${
defaultOptions
}
`
(
'
$description
'
,
({
instance
,
options
}
=
{})
=>
{
`
(
'
$description
'
,
({
instance
,
options
}
=
{})
=>
{
EditorLiteExtension
.
deferRerender
=
jest
.
fn
();
const
originalInstance
=
{
...
instance
};
const
originalInstance
=
{
...
instance
};
if
(
instance
)
{
if
(
instance
)
{
...
@@ -82,12 +111,14 @@ describe('The basis for an Editor Lite extension', () => {
...
@@ -82,12 +111,14 @@ describe('The basis for an Editor Lite extension', () => {
});
});
it
(
'
initializes the line highlighting
'
,
()
=>
{
it
(
'
initializes the line highlighting
'
,
()
=>
{
EditorLiteExtension
.
deferRerender
=
jest
.
fn
();
const
spy
=
jest
.
spyOn
(
EditorLiteExtension
,
'
highlightLines
'
);
const
spy
=
jest
.
spyOn
(
EditorLiteExtension
,
'
highlightLines
'
);
ext
=
new
EditorLiteExtension
({
instance
:
{}
});
ext
=
new
EditorLiteExtension
({
instance
:
{}
});
expect
(
spy
).
toHaveBeenCalled
();
expect
(
spy
).
toHaveBeenCalled
();
});
});
it
(
'
sets up the line linking for code instance
'
,
()
=>
{
it
(
'
sets up the line linking for code instance
'
,
()
=>
{
EditorLiteExtension
.
deferRerender
=
jest
.
fn
();
const
spy
=
jest
.
spyOn
(
EditorLiteExtension
,
'
setupLineLinking
'
);
const
spy
=
jest
.
spyOn
(
EditorLiteExtension
,
'
setupLineLinking
'
);
const
instance
=
{
const
instance
=
{
getEditorType
:
jest
.
fn
().
mockReturnValue
(
EDITOR_TYPE_CODE
),
getEditorType
:
jest
.
fn
().
mockReturnValue
(
EDITOR_TYPE_CODE
),
...
@@ -99,6 +130,7 @@ describe('The basis for an Editor Lite extension', () => {
...
@@ -99,6 +130,7 @@ describe('The basis for an Editor Lite extension', () => {
});
});
it
(
'
does not set up the line linking for diff instance
'
,
()
=>
{
it
(
'
does not set up the line linking for diff instance
'
,
()
=>
{
EditorLiteExtension
.
deferRerender
=
jest
.
fn
();
const
spy
=
jest
.
spyOn
(
EditorLiteExtension
,
'
setupLineLinking
'
);
const
spy
=
jest
.
spyOn
(
EditorLiteExtension
,
'
setupLineLinking
'
);
const
instance
=
{
const
instance
=
{
getEditorType
:
jest
.
fn
().
mockReturnValue
(
EDITOR_TYPE_DIFF
),
getEditorType
:
jest
.
fn
().
mockReturnValue
(
EDITOR_TYPE_DIFF
),
...
...
spec/frontend/pipeline_editor/components/editor/text_editor_spec.js
View file @
1b954408
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
EDITOR_READY_EVENT
}
from
'
~/editor/constants
'
;
import
{
EDITOR_READY_EVENT
}
from
'
~/editor/constants
'
;
import
{
EditorLiteExtension
}
from
'
~/editor/extensions/editor_lite_extension_base
'
;
import
TextEditor
from
'
~/pipeline_editor/components/editor/text_editor.vue
'
;
import
TextEditor
from
'
~/pipeline_editor/components/editor/text_editor.vue
'
;
import
{
import
{
mockCiConfigPath
,
mockCiConfigPath
,
...
@@ -59,6 +60,10 @@ describe('Pipeline Editor | Text editor component', () => {
...
@@ -59,6 +60,10 @@ describe('Pipeline Editor | Text editor component', () => {
const
findEditor
=
()
=>
wrapper
.
findComponent
(
MockEditorLite
);
const
findEditor
=
()
=>
wrapper
.
findComponent
(
MockEditorLite
);
beforeEach
(()
=>
{
EditorLiteExtension
.
deferRerender
=
jest
.
fn
();
});
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
wrapper
=
null
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment