From 94f90b3424fcab9b0770e2b01c86fc5f407a33fc Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Thu, 26 Apr 2018 11:47:45 -0400 Subject: [PATCH] Link to the currently-selected channel's error index Fixes #207 --- ui/frontend/highlighting.ts | 4 ++-- ui/frontend/index.tsx | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/frontend/highlighting.ts b/ui/frontend/highlighting.ts index bb9de5778..e66688e3d 100644 --- a/ui/frontend/highlighting.ts +++ b/ui/frontend/highlighting.ts @@ -1,6 +1,6 @@ import Prism from 'prismjs'; -export function configureRustErrors(gotoPosition) { +export function configureRustErrors({ gotoPosition, getChannel }) { Prism.languages.rust_errors = { // eslint-disable-line camelcase 'warning': /warning:.*\n/, 'error': { @@ -19,7 +19,7 @@ export function configureRustErrors(gotoPosition) { const errorMatch = /E\d+/.exec(env.content); const [errorCode] = errorMatch; env.tag = 'a'; - env.attributes.href = `https://doc.rust-lang.org/error-index.html#${errorCode}`; + env.attributes.href = `https://doc.rust-lang.org/${getChannel()}/error-index.html#${errorCode}`; } if (env.type === 'see-issue') { const errorMatch = /\d+/.exec(env.content); diff --git a/ui/frontend/index.tsx b/ui/frontend/index.tsx index dc2884725..d4ea13b57 100644 --- a/ui/frontend/index.tsx +++ b/ui/frontend/index.tsx @@ -20,7 +20,10 @@ const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; const enhancers = composeEnhancers(middlewares, persistState(undefined, { serialize, deserialize })); const store = createStore(playgroundApp, enhancers); -configureRustErrors((line, col) => store.dispatch(gotoPosition(line, col))); +configureRustErrors({ + gotoPosition: (line, col) => store.dispatch(gotoPosition(line, col)), + getChannel: () => store.getState().configuration.channel, +}); store.dispatch(performCratesLoad()); store.dispatch(performVersionsLoad());