Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
5b5976a6
Commit
5b5976a6
authored
9 years ago
by
Devin Abbott
Committed by
Marijn Haverbeke
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[jsx mode] Improve indention of js blocks
Issue #3745
parent
5b4f2241
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mode/jsx/jsx.js
+16
-1
16 additions, 1 deletion
mode/jsx/jsx.js
mode/jsx/test.js
+2
-2
2 additions, 2 deletions
mode/jsx/test.js
with
18 additions
and
3 deletions
mode/jsx/jsx.js
+
16
−
1
View file @
5b5976a6
...
...
@@ -53,7 +53,22 @@
if
(
stream
.
peek
()
==
"
{
"
)
{
xmlMode
.
skipAttribute
(
cx
.
state
)
state
.
context
=
new
Context
(
CodeMirror
.
startState
(
jsMode
,
flatXMLIndent
(
cx
.
state
)),
var
indent
=
flatXMLIndent
(
cx
.
state
),
xmlContext
=
cx
.
state
.
context
// If JS starts on same line as tag
if
(
xmlContext
&&
stream
.
string
.
slice
(
0
,
stream
.
pos
).
match
(
/>
\s
*$/
))
{
while
(
xmlContext
.
prev
&&
!
xmlContext
.
startOfLine
)
xmlContext
=
xmlContext
.
prev
// If tag starts the line, use XML indentation level
if
(
xmlContext
.
startOfLine
)
indent
-=
config
.
indentUnit
// Else use JS indentation level
else
if
(
cx
.
prev
.
state
.
lexical
)
indent
=
cx
.
prev
.
state
.
lexical
.
indented
// Else if inside of tag
}
else
if
(
cx
.
depth
==
1
)
{
indent
+=
config
.
indentUnit
}
state
.
context
=
new
Context
(
CodeMirror
.
startState
(
jsMode
,
indent
),
jsMode
,
0
,
state
.
context
)
return
null
}
...
...
This diff is collapsed.
Click to expand it.
mode/jsx/test.js
+
2
−
2
View file @
5b5976a6
...
...
@@ -57,8 +57,8 @@
MT
(
"
indent_js
"
,
"
([bracket&tag <][tag foo][bracket&tag >]
"
,
"
[bracket&tag <][tag bar] [attribute baz]={[keyword function]() {
"
,
"
[keyword return] [number 10]
"
,
"
}}[bracket&tag />]
"
,
"
[keyword return] [number 10]
"
,
"
}}[bracket&tag />]
"
,
"
[bracket&tag </][tag foo][bracket&tag >])
"
)
MT
(
"
spread
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment