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 2525 };
2626 let current = 'foo';
2727 let color = 'red';
28+ let active = true;
2829<` +
2930 ` /script>
3031
7778 preprocess,
7879 postprocess,
7980 }
81+ let editor
8082
8183 $: serializedString = (() => {
8284 const serializeCode = DEFAULT_CODE === code ? undefined : code
122124 }
123125 return true
124126 }
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+ }
125144< / script>
126145
127146< svelte: window on: hashchange= {onUrlHashChange} / >
134153 < RulesSettings bind: rules / >
135154 < div class = " editor-content" >
136155 < ESLintEditor
156+ bind: this = {editor}
137157 {linter}
138158 bind: code
139159 config= {{
155175 < ol>
156176 {#each messages as msg, i (` ${ msg .line } :${ msg .column } :${ msg .ruleId } @${ i} ` )}
157177 < 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+ > :
159184 {msg .message }
160185 < a
161186 class = " rule-link {getRule(msg.ruleId)?.classes}"
228253 .rule - link .core - rule: hover {
229254 color: #8080f2 ;
230255 }
256+ .message - link {
257+ color: #40b3ff ;
258+ }
231259< / style>
Original file line number Diff line number Diff line change 1717 let rightMarkers = []
1818
1919 let messageMap = new Map ()
20+ let editor
21+
22+ export function setCursorPosition (loc ) {
23+ if (editor) {
24+ editor .setCursorPosition (loc)
25+ }
26+ }
2027
2128 $: showApplyFix = fix && fixedValue !== code
2229 $: {
211218
212219<div class =" eslint-editor" >
213220 <MonacoEditor
221+ bind:this ={editor }
214222 bind:code
215223 bind:rightCode ={fixedValue }
216224 language =" html"
Original file line number Diff line number Diff line change 185185 destroy ()
186186 })
187187
188- export function setCursorPosition (loc , { columnOffset = 0 } = {} ) {
188+ export function setCursorPosition (loc ) {
189189 if (editor) {
190190 const leftEditor = diffEditor ? editor? .getOriginalEditor () : editor
191191 leftEditor .setSelection ({
192192 startLineNumber: loc .start .line ,
193- startColumn: loc .start .column + columnOffset ,
193+ startColumn: loc .start .column ,
194194 endLineNumber: loc .end .line ,
195- endColumn: loc .end .column + columnOffset ,
195+ endColumn: loc .end .column ,
196196 })
197+ leftEditor .revealLineInCenter (loc .start .line )
197198 }
198199 }
199200 async function updateMarkers (editor , markers ) {
You can’t perform that action at this time.
0 commit comments