Skip to content

Commit 1f699e5

Browse files
Kateryna ProkopenkoDevtools-frontend LUCI CQ
authored andcommitted
[GM3Restyling] Update go to line menu
Screenshot: https://imgur.com/a/erVH2EJ Bug: 325442580 Change-Id: I169f963a5a480e33f2c14b110bf707185c32c887 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6172721 Commit-Queue: Kateryna Prokopenko <[email protected]> Auto-Submit: Kateryna Prokopenko <[email protected]> Reviewed-by: Kim-Anh Tran <[email protected]>
1 parent 6d82538 commit 1f699e5

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

front_end/panels/sources/GoToLineQuickOpen.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import * as i18n from '../../core/i18n/i18n.js';
6+
import * as IconButton from '../../ui/components/icon_button/icon_button.js';
67
import * as QuickOpen from '../../ui/legacy/components/quick_open/quick_open.js';
78
import * as UI from '../../ui/legacy/legacy.js';
89

@@ -13,45 +14,42 @@ const UIStrings = {
1314
/**
1415
*@description Text in Go To Line Quick Open of the Sources panel
1516
*/
16-
noFileSelected: 'No file selected.',
17+
noFileSelected: 'No file selected',
1718
/**
1819
*@description Text to show no results have been found
1920
*/
2021
noResultsFound: 'No results found',
2122
/**
2223
*@description Text in Go To Line Quick Open of the Sources panel
2324
*/
24-
typeANumberToGoToThatLine: 'Type a number to go to that line.',
25+
typeANumberToGoToThatLine: 'Type a number to go to that line',
2526
/**
2627
*@description Text in Go To Line Quick Open of the Sources panel
27-
*@example {abc} PH1
28-
*@example {000} PH2
29-
*@example {bbb} PH3
28+
*@example {000} PH1
29+
*@example {bbb} PH2
3030
*/
31-
currentPositionXsTypeAnOffset:
32-
'Current position: 0x{PH1}. Type an offset between 0x{PH2} and 0x{PH3} to navigate to.',
31+
currentPositionXsTypeAnOffset: 'Type an offset between 0x{PH1} and 0x{PH2} to navigate to',
3332
/**
3433
*@description Text in the GoToLine dialog of the Sources pane that describes the current line number, file line number range, and use of the GoToLine dialog
35-
*@example {1} PH1
36-
*@example {100} PH2
34+
*@example {100} PH1
3735
*/
38-
currentLineSTypeALineNumber: 'Current line: {PH1}. Type a line number between 1 and {PH2} to navigate to.',
36+
currentLineSTypeALineNumber: 'Type a line number between 1 and {PH1} to navigate to',
3937
/**
4038
*@description Text in Go To Line Quick Open of the Sources panel
4139
*@example {abc} PH1
4240
*/
43-
goToOffsetXs: 'Go to offset 0x{PH1}.',
41+
goToOffsetXs: 'Go to offset 0x{PH1}',
4442
/**
4543
*@description Text in Go To Line Quick Open of the Sources panel
4644
*@example {2} PH1
4745
*@example {2} PH2
4846
*/
49-
goToLineSAndColumnS: 'Go to line {PH1} and column {PH2}.',
47+
goToLineSAndColumnS: 'Go to line {PH1} and column {PH2}',
5048
/**
5149
*@description Text in Go To Line Quick Open of the Sources panel
5250
*@example {2} PH1
5351
*/
54-
goToLineS: 'Go to line {PH1}.',
52+
goToLineS: 'Go to line {PH1}',
5553
};
5654
const str_ = i18n.i18n.registerUIStrings('panels/sources/GoToLineQuickOpen.ts', UIStrings);
5755
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
@@ -80,6 +78,8 @@ export class GoToLineQuickOpen extends QuickOpen.FilteredListWidget.Provider {
8078
}
8179

8280
override renderItem(itemIndex: number, _query: string, titleElement: Element, _subtitleElement: Element): void {
81+
const icon = IconButton.Icon.create('colon');
82+
titleElement.parentElement?.parentElement?.insertBefore(icon, titleElement.parentElement);
8383
UI.UIUtils.createTextChild(titleElement, this.#goToLineStrings[itemIndex]);
8484
}
8585

@@ -99,23 +99,17 @@ export class GoToLineQuickOpen extends QuickOpen.FilteredListWidget.Provider {
9999
}
100100
const editorState = sourceFrame.textEditor.state;
101101
const disassembly = sourceFrame.wasmDisassembly;
102-
const currentLineNumber =
103-
sourceFrame.editorLocationToUILocation(editorState.doc.lineAt(editorState.selection.main.head).number - 1)
104-
.lineNumber;
105102
if (disassembly) {
106103
const lastBytecodeOffset = disassembly.lineNumberToBytecodeOffset(disassembly.lineNumbers - 1);
107104
const bytecodeOffsetDigits = lastBytecodeOffset.toString(16).length;
108-
const currentPosition = disassembly.lineNumberToBytecodeOffset(currentLineNumber);
109105
this.#goToLineStrings.push(i18nString(UIStrings.currentPositionXsTypeAnOffset, {
110-
PH1: currentPosition.toString(16).padStart(bytecodeOffsetDigits, '0'),
111-
PH2: '0'.padStart(bytecodeOffsetDigits, '0'),
112-
PH3: lastBytecodeOffset.toString(16),
106+
PH1: '0'.padStart(bytecodeOffsetDigits, '0'),
107+
PH2: lastBytecodeOffset.toString(16),
113108
}));
114109
return;
115110
}
116111
const linesCount = sourceFrame.editorLocationToUILocation(editorState.doc.lines - 1).lineNumber + 1;
117-
this.#goToLineStrings.push(
118-
i18nString(UIStrings.currentLineSTypeALineNumber, {PH1: currentLineNumber + 1, PH2: linesCount}));
112+
this.#goToLineStrings.push(i18nString(UIStrings.currentLineSTypeALineNumber, {PH1: linesCount}));
119113
return;
120114
}
121115

0 commit comments

Comments
 (0)