File tree Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 25
25
};
26
26
let current = 'foo';
27
27
let color = 'red';
28
+ let active = true;
28
29
<` +
29
30
` /script>
30
31
77
78
preprocess,
78
79
postprocess,
79
80
}
81
+ let editor
80
82
81
83
$: serializedString = (() => {
82
84
const serializeCode = DEFAULT_CODE === code ? undefined : code
122
124
}
123
125
return true
124
126
}
127
+
128
+ function onClickMessage (evt , msg ) {
129
+ evt .stopPropagation ()
130
+ evt .preventDefault ()
131
+ if (editor) {
132
+ editor .setCursorPosition ({
133
+ start: {
134
+ line: msg .line ,
135
+ column: msg .column ,
136
+ },
137
+ end: {
138
+ line: msg .endLine ?? msg .line ,
139
+ column: msg .endColumn ?? msg .column ,
140
+ },
141
+ })
142
+ }
143
+ }
125
144
< / script>
126
145
127
146
< svelte: window on: hashchange= {onUrlHashChange} / >
134
153
< RulesSettings bind: rules / >
135
154
< div class = " editor-content" >
136
155
< ESLintEditor
156
+ bind: this = {editor}
137
157
{linter}
138
158
bind: code
139
159
config= {{
155
175
< ol>
156
176
{#each messages as msg, i (` ${ msg .line } :${ msg .column } :${ msg .ruleId } @${ i} ` )}
157
177
< li class = " message" >
158
- [{msg .line }:{msg .column }]:
178
+ <!-- svelte- ignore a11y- invalid- attribute -->
179
+ < a
180
+ href= " #"
181
+ on: click= {(evt ) => onClickMessage (evt, msg)}
182
+ class = " message-link" > [{msg .line }: {msg .column }]< / a
183
+ > :
159
184
{msg .message }
160
185
< a
161
186
class = " rule-link {getRule(msg.ruleId)?.classes}"
228
253
.rule - link .core - rule: hover {
229
254
color: #8080f2 ;
230
255
}
256
+ .message - link {
257
+ color: #40b3ff ;
258
+ }
231
259
< / style>
Original file line number Diff line number Diff line change 17
17
let rightMarkers = []
18
18
19
19
let messageMap = new Map ()
20
+ let editor
21
+
22
+ export function setCursorPosition (loc ) {
23
+ if (editor) {
24
+ editor .setCursorPosition (loc)
25
+ }
26
+ }
20
27
21
28
$: showApplyFix = fix && fixedValue !== code
22
29
$: {
211
218
212
219
<div class =" eslint-editor" >
213
220
<MonacoEditor
221
+ bind:this ={editor }
214
222
bind:code
215
223
bind:rightCode ={fixedValue }
216
224
language =" html"
Original file line number Diff line number Diff line change 185
185
destroy ()
186
186
})
187
187
188
- export function setCursorPosition (loc , { columnOffset = 0 } = {} ) {
188
+ export function setCursorPosition (loc ) {
189
189
if (editor) {
190
190
const leftEditor = diffEditor ? editor? .getOriginalEditor () : editor
191
191
leftEditor .setSelection ({
192
192
startLineNumber: loc .start .line ,
193
- startColumn: loc .start .column + columnOffset ,
193
+ startColumn: loc .start .column ,
194
194
endLineNumber: loc .end .line ,
195
- endColumn: loc .end .column + columnOffset ,
195
+ endColumn: loc .end .column ,
196
196
})
197
+ leftEditor .revealLineInCenter (loc .start .line )
197
198
}
198
199
}
199
200
async function updateMarkers (editor , markers ) {
You can’t perform that action at this time.
0 commit comments