-
Notifications
You must be signed in to change notification settings - Fork 26
Data editor: add profile source target selection #1564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ See the License for the specific language governing permissions and | |
| limitations under the License. | ||
| --> | ||
| <script lang="ts"> | ||
| let profileTarget: 'editor' | 'disk' = 'editor' | ||
| import Button from '../Inputs/Buttons/Button.svelte' | ||
| import { vscode } from '../../utilities/vscode' | ||
| import { MessageCommand } from '../../utilities/message' | ||
|
|
@@ -73,7 +74,6 @@ limitations under the License. | |
| let errorMessageTimeout: NodeJS.Timeout | null = null | ||
| let asciiOverlay: boolean = true | ||
| let logScale: boolean = false | ||
|
|
||
| $: { | ||
| sum = byteProfile.reduce((a, b) => a + b, 0) | ||
| mean = sum / byteProfile.length | ||
|
|
@@ -157,20 +157,27 @@ limitations under the License. | |
| }) | ||
| } | ||
|
|
||
| let lastProfileTarget: 'editor' | 'disk' | null = null | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this variable instance type is used in multiple places it should be extracted to a concrete type definition: type ProfileTarget = 'editor' | 'disk'Then change the appropriate variable's types: let lastProfileTarget: ProfileTarget | undefined = undefined
let lastRequestedTarget: ProfileTarget = 'editor' |
||
| let lastRequestedTarget: 'editor' | 'disk' = 'editor' | ||
| function requestSessionProfile(startOffset: number, length: number) { | ||
| lastRequestedTarget = profileTarget | ||
| setStatusMessage( | ||
| `Profiling bytes from ${startOffset} to ${startOffset + length}...`, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove the |
||
| 0 | ||
| ) | ||
| vscode.postMessage({ | ||
| command: MessageCommand.profile, | ||
| data: { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a data object above this type ProfileMsg = {
startOffset: number,
length: number,
target: ProfileTarget
}
...
const profileTargetData: ProfileMsg = {
startOffset,
length,
target: profileTarget === 'disk' ? 'disk' : 'editor'
}
vscode.postMessage({
...
data: {...profileTarget}
}I'm also unsure as to why the target would be set to undefined if the target was |
||
| startOffset: startOffset, | ||
| length: length, | ||
| startOffset, | ||
| length, | ||
| target: profileTarget === 'disk' ? 'disk' : undefined, | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| $: if (profileTarget !== lastProfileTarget) { | ||
| lastProfileTarget = profileTarget | ||
| requestSessionProfile(startOffset, length) | ||
| } | ||
| function handleInputEnter(e: CustomEvent) { | ||
| switch (e.detail.id) { | ||
| case 'start-offset-input': | ||
|
|
@@ -283,6 +290,10 @@ limitations under the License. | |
| window.addEventListener('message', (msg) => { | ||
| switch (msg.data.command) { | ||
| case MessageCommand.profile: | ||
| if (msg.data.data?.target && msg.data.data.target !== profileTarget) { | ||
| // ignore messages not for the current profile target | ||
| break | ||
| } | ||
| numAscii = msg.data.data.numAscii as number | ||
| byteProfile = msg.data.data.byteProfile as number[] | ||
| language = msg.data.data.language as string | ||
|
|
@@ -313,11 +324,19 @@ limitations under the License. | |
| } | ||
| }) | ||
| endOffset = startOffset + length | ||
| requestSessionProfile(startOffset, length) | ||
| }) | ||
| </script> | ||
|
|
||
| <div class="container"> | ||
| <div class="input-container"> | ||
| <label> | ||
| Profile source: | ||
| <select bind:value={profileTarget}> | ||
| <option value="editor">Current editor</option> | ||
| <option value="disk">On-disk file</option> | ||
| </select> | ||
| </label> | ||
| </div> | ||
| {#if title.length > 0} | ||
| <div class="header"> | ||
| <h3>{title}</h3> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling the
createSessionAPI function is emitting the following error from Omega Edit server:I don't currently have a resolution off the top of my head so you may have to read up on the exposed API functions to work around this.