Skip to content

Commit 557da07

Browse files
committed
Only show edit menu item if it is possible to edit
And actually fix the edit menu item Closes #50
1 parent b734fd8 commit 557da07

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

static/rustw.out.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,6 @@ exports.make_url = make_url;
887887
exports.highlight_spans = highlight_spans;
888888
exports.request = request;
889889
exports.parseLink = parseLink;
890-
exports.edit = edit;
891890
// Copyright 2017 The Rustw Project Developers.
892891
//
893892
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
@@ -1015,12 +1014,6 @@ function parseLink(file_loc) {
10151014
return data;
10161015
}
10171016

1018-
function edit(target) {
1019-
request('edit?file=' + target.dataset.link, function (json) {
1020-
console.log("edit - success");
1021-
}, "Error with search edit", null);
1022-
}
1023-
10241017
// Left is the number of chars from the left margin to where the highlight
10251018
// should start. right is the number of chars to where the highlight should end.
10261019
// If right == 0, we take it as the last char in the line.
@@ -7469,7 +7462,10 @@ function add_ref_functionality(self) {
74697462
// props: location, onClose, target
74707463
// location: { "top": event.pageY, "left": event.pageX }
74717464
function LineNumberMenu(props) {
7472-
var items = [{ id: "line_number_menu_edit", label: "edit", fn: utils.edit, unstable: true }];
7465+
var items = [];
7466+
if (CONFIG.edit_command) {
7467+
items.push({ id: "line_number_menu_edit", label: "edit", fn: edit, unstable: true });
7468+
}
74737469
if (CONFIG.vcs_link) {
74747470
items.push({ id: "line_number_vcs", label: "view in VCS", fn: view_in_vcs });
74757471
}
@@ -7515,6 +7511,12 @@ function view_in_vcs(target) {
75157511
window.open(CONFIG.vcs_link.replace("$file", file_name).replace("$line", line_number), '_blank');
75167512
}
75177513

7514+
function edit(target) {
7515+
utils.request('edit?file=' + target.dataset.link, function (json) {
7516+
console.log("edit - success");
7517+
}, "Error with search edit", null);
7518+
}
7519+
75187520
// See https://github.com/Microsoft/TypeScript/issues/18134
75197521
/** @augments {React.Component<object, object>} */
75207522

static/rustw.out.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/srcView.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ function add_ref_functionality(self) {
4545
// props: location, onClose, target
4646
// location: { "top": event.pageY, "left": event.pageX }
4747
function LineNumberMenu(props) {
48-
let items = [
49-
{ id: "line_number_menu_edit", label: "edit", fn: utils.edit, unstable: true }
50-
];
48+
let items = [];
49+
if (CONFIG.edit_command) {
50+
items.push({ id: "line_number_menu_edit", label: "edit", fn: edit, unstable: true });
51+
}
5152
if (CONFIG.vcs_link) {
5253
items.push({ id: "line_number_vcs", label: "view in VCS", fn: view_in_vcs });
5354
}
@@ -87,6 +88,17 @@ function view_in_vcs(target) {
8788
window.open(CONFIG.vcs_link.replace("$file", file_name).replace("$line", line_number), '_blank');
8889
}
8990

91+
function edit(target) {
92+
utils.request(
93+
'edit?file=' + target.dataset.link,
94+
function(json) {
95+
console.log("edit - success");
96+
},
97+
"Error with search edit",
98+
null
99+
);
100+
}
101+
90102
// See https://github.com/Microsoft/TypeScript/issues/18134
91103
/** @augments {React.Component<object, object>} */
92104
export class SourceView extends React.Component {

static/utils.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,6 @@ export function parseLink(file_loc) {
127127
return data;
128128
}
129129

130-
export function edit(target) {
131-
request(
132-
'edit?file=' + target.dataset.link,
133-
function(json) {
134-
console.log("edit - success");
135-
},
136-
"Error with search edit",
137-
null
138-
);
139-
}
140-
141130
// Left is the number of chars from the left margin to where the highlight
142131
// should start. right is the number of chars to where the highlight should end.
143132
// If right == 0, we take it as the last char in the line.

0 commit comments

Comments
 (0)