mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-03 02:21:05 +08:00
This reverts commit abcb8f7aa8.
Reason for revert: Consistently causing autoroll issues when rolling devtools-frontend into Chromium - see https://chromium-review.googlesource.com/c/chromium/src/+/2554521 for an example.
To recreate this, do a debug build of Chromium with this patch applied to DevTools. It's causing an issue with duplicate keys in the pak files. No DevTools Frontend builds do a debug build of Chromium with the DevTools frontend patch applied so our CQ will be green despite causing an issue.
You can run this locally in Chromium to reproduce via:
autoninja -C out/Default chrome:packed_resources_extra
Which will show the error.
Original change's description:
> [Loc] Migrate changes tool to localization V2
>
> Migrate changes tool
> Tested with en-XL: https://imgur.com/a/hFDBjQV
>
>
> Bug: 1136655
> Change-Id: Ic434c3085b9e2f2cf44583cca7ee1ce8f1d412f2
> Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2548688
> Commit-Queue: Christy Chen <chrche@microsoft.com>
> Reviewed-by: Simon Zünd <szuend@chromium.org>
TBR=szuend@chromium.org,chrche@microsoft.com
Change-Id: I94b27434562f6a6bff3be381ab8a5802bd8b03f9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1136655
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2557044
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
104 lines
3.6 KiB
JavaScript
104 lines
3.6 KiB
JavaScript
// Copyright 2019 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import * as TextEditor from '../text_editor/text_editor.js';
|
|
import * as UI from '../ui/ui.js'; // eslint-disable-line no-unused-vars
|
|
|
|
import {Row, RowType} from './ChangesView.js'; // eslint-disable-line no-unused-vars
|
|
|
|
/**
|
|
* @extends {TextEditor.CodeMirrorTextEditor.CodeMirrorTextEditor}
|
|
*/
|
|
export class ChangesTextEditor extends TextEditor.CodeMirrorTextEditor.CodeMirrorTextEditor {
|
|
/**
|
|
* @param {!UI.TextEditor.Options} options
|
|
*/
|
|
constructor(options) {
|
|
options.inputStyle = 'devToolsAccessibleDiffTextArea';
|
|
super(options);
|
|
this.codeMirror().setOption('gutters', ['CodeMirror-linenumbers', 'changes-diff-gutter']);
|
|
this.codeMirror().setOption('extraKeys', {
|
|
Enter: false,
|
|
Space: false,
|
|
/**
|
|
* @param {!CodeMirror.Editor} cm
|
|
*/
|
|
Left: function(cm) {
|
|
const scrollInfo = cm.getScrollInfo();
|
|
// Left edge check required due to bug where line numbers would disappear when attempting to scroll left when the scrollbar is at the leftmost point.
|
|
// CodeMirror Issue: https://github.com/codemirror/CodeMirror/issues/6139
|
|
if (scrollInfo.left > 0) {
|
|
cm.scrollTo(scrollInfo.left - Math.round(scrollInfo.clientWidth / 6), null);
|
|
}
|
|
},
|
|
/**
|
|
* @param {!CodeMirror.Editor} cm
|
|
*/
|
|
Right: function(cm) {
|
|
const scrollInfo = cm.getScrollInfo();
|
|
cm.scrollTo(scrollInfo.left + Math.round(scrollInfo.clientWidth / 6), null);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @param {!Array<!Row>} diffRows
|
|
*/
|
|
updateDiffGutter(diffRows) {
|
|
this.codeMirror().eachLine(/** @param {!CodeMirror.LineHandle} line */ line => {
|
|
const lineNumber = this.codeMirror().getLineNumber(line);
|
|
const row = diffRows[lineNumber];
|
|
let gutterMarker;
|
|
if (row.type === RowType.Deletion) {
|
|
gutterMarker = document.createElement('div');
|
|
gutterMarker.classList.add('deletion');
|
|
gutterMarker.classList.add('changes-diff-gutter-marker');
|
|
gutterMarker.textContent = '-';
|
|
} else if (row.type === RowType.Addition) {
|
|
gutterMarker = document.createElement('div');
|
|
gutterMarker.classList.add('addition');
|
|
gutterMarker.classList.add('changes-diff-gutter-marker');
|
|
gutterMarker.textContent = '+';
|
|
}
|
|
if (gutterMarker) {
|
|
this.codeMirror().setGutterMarker(line, 'changes-diff-gutter', gutterMarker);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
export class DevToolsAccessibleDiffTextArea extends TextEditor.CodeMirrorTextEditor.DevToolsAccessibleTextArea {
|
|
/**
|
|
* @override
|
|
* @param {boolean=} typing - whether the user is currently typing
|
|
*/
|
|
reset(typing) {
|
|
super.reset(typing);
|
|
// TODO(crbug.com/1011811): Update CodeMirror typings to include this property
|
|
const doc = /** @type {!CodeMirror.Doc} */ (/** @type {*} */ (this.cm).doc);
|
|
if (this.textAreaBusy(!!typing) || !(typeof doc.modeOption === 'object')) {
|
|
return;
|
|
}
|
|
|
|
const diffRows = doc.modeOption.diffRows;
|
|
const lineNumber = this.cm.getCursor().line;
|
|
const rowType = diffRows[lineNumber].type;
|
|
|
|
if (rowType === RowType.Deletion) {
|
|
this.textarea.value = ls`Deletion:${this.textarea.value}`;
|
|
}
|
|
if (rowType === RowType.Addition) {
|
|
this.textarea.value = ls`Addition:${this.textarea.value}`;
|
|
}
|
|
this.prevInput = this.textarea.value;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @constructor
|
|
*/
|
|
// @ts-ignore CodeMirror integration with externals, not yet part of codemirror-legacy.d.ts
|
|
CodeMirror.inputStyles.devToolsAccessibleDiffTextArea = DevToolsAccessibleDiffTextArea;
|