Skip to content

Commit adf9b59

Browse files
authored
FE exercise patch (exercism#7853)
* Avoid double adjusting col numbers * Remove unused files, console logs
1 parent 7429d36 commit adf9b59

File tree

5 files changed

+7
-343
lines changed

5 files changed

+7
-343
lines changed

app/javascript/components/bootcamp/FrontendExercisePage/FrontendExercisePage.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { useSetupEditors } from './hooks/useSetupEditors'
88
import { useSetupIFrames } from './hooks/useSetupIFrames'
99
import { LHS } from './LHS/LHS'
1010
import { RHS } from './RHS/RHS'
11-
import { useLogger } from '../common/hooks/useLogger'
1211
import { useRestoreIframeScrollAfterResize } from './hooks/useRestoreIframeScrollAfterResize'
1312

1413
export default function FrontendExercisePage(data: FrontendExercisePageProps) {
@@ -17,8 +16,6 @@ export default function FrontendExercisePage(data: FrontendExercisePageProps) {
1716

1817
const { handleWidthChangeMouseDown } = useInitResizablePanels()
1918

20-
useLogger('data', data)
21-
2219
const {
2320
htmlEditorViewRef,
2421
cssEditorViewRef,

app/javascript/components/bootcamp/FrontendExercisePage/LHS/showJsError.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function showJsError(
2222

2323
const editorLength = view.state.doc.length
2424
const errorLine = view.state.doc.line(error.lineNumber)
25-
const basePos = errorLine.from + error.colNumber
25+
const basePos = errorLine.from + error.colNumber - 1
2626

2727
// range rules to avoid breaking:
2828
// from < to
@@ -31,8 +31,6 @@ export function showJsError(
3131
const from = Math.max(1, Math.min(basePos, editorLength - 1))
3232
const to = Math.min(editorLength, from + 1)
3333

34-
console.log('editorleng', editorLength)
35-
3634
view.dispatch({
3735
effects: [
3836
showInfoWidgetEffect.of(true),

app/javascript/components/bootcamp/FrontendExercisePage/LHS/useHandleJsErrorMessage.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ export function useHandleJsErrorMessage({
2323

2424
const { column, line } = extractLineAndColumnFromStack(data.stack)
2525

26-
const adjustedLineNumber = line - jsLineOffset
27-
const lineNumberAbsolutePosition =
28-
jsViewRef.current?.state.doc.line(adjustedLineNumber).from ?? 0
29-
const adjustedColumnNumber = lineNumberAbsolutePosition + column - 1
26+
const adjustedLineNumber = Math.min(
27+
Math.max(1, line - jsLineOffset),
28+
jsViewRef.current?.state.doc.lines || 1
29+
)
3030

3131
showJsError(jsViewRef.current, {
3232
message: data.message,
33-
colNumber: adjustedColumnNumber,
33+
// column gets adjusted + positioned in showJsError
34+
colNumber: column,
3435
lineNumber: adjustedLineNumber,
3536
})
3637
}

app/javascript/components/bootcamp/FrontendExercisePage/defaultStyles.ts

Lines changed: 0 additions & 294 deletions
This file was deleted.

app/javascript/components/bootcamp/FrontendExercisePage/utils/getIframesMatchPercentage.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)